DarthMike / indielib-crossplatform

IndieLib is a cross-platform Game Graphics engine. Main focus is OpenGL ES 2.0 for mobile iOS operating system, and OpenGL desktop. **NOT SUPPORTED ANYMORE**
zlib License
61 stars 27 forks source link

Building project on Linux #143

Closed SerhiiYashchuk closed 10 years ago

SerhiiYashchuk commented 10 years ago

When I try to build my project I get a lot of "undefined reference to" errors. This is my first project on Linux, so I have no guess what should I do. All my projects were built on Windows without any problems.

DarthMike commented 10 years ago

Have you followed the steps in wiki? http://indielib.com/wiki/index.php?title=Building_IndieLib

SerhiiYashchuk commented 10 years ago

Yeah. I've built all the dependencies as it is said in wiki. Even if I try to build the first tutorial, I get that errors.

SerhiiYashchuk commented 10 years ago

When I got similar error on Windows, I just added "#pragma comment (lib, "IndieLib.lib")" to CIndieLib_vc2008.h and it worked. But I can't do the same here.

DarthMike commented 10 years ago

Hm, what error do you get exactly? We moved along from having the Visual studio pragma to link. Lib should be linked by compiler settings. It would be good to know what distro you are running too.

SerhiiYashchuk commented 10 years ago

I get "undefined reference to " for all the IndieLib functions that are called. I use Ubuntu 12.04.

DarthMike commented 10 years ago

By the way, you can take a look at our configuration for the test and tutorials to link against the library.

You will need LD flag, to link against indielib: -lIndieLib

For example, for tutorial 01 automake file: https://github.com/DarthMike/indielib-crossplatform/blob/master/IndieLib/linux/tutorials/basic/01_Installing/Makefile.am

SerhiiYashchuk commented 10 years ago

Where do I have to use this flag?

SerhiiYashchuk commented 10 years ago

By the way, if I remove that pragma I get this: CIndieLib_vc2008.obj : error LNK2019: unresolved external symbol "declspec(dllimport) public: bool thiscall IND_Math::init(void)" ...

DarthMike commented 10 years ago

Hm. that declaration is windows, not linux code. What version of indielib are you trying to build against? Did you try latest master? I've compiled it just now under Debian.

SerhiiYashchuk commented 10 years ago

Ok. I'll try to add that flag.

DarthMike commented 10 years ago

can you update to latest master? It's quite stable right now. If you can post any makefile here we can help you in getting it right to link against Indielib

SerhiiYashchuk commented 10 years ago

I use the latest version. Updated two hours ago. I use Code::Blocks, so I have no idea about makefile. (Have no experience in building on Linux).

DarthMike commented 10 years ago

Hmm, I never used Code::Blocks... BUT, you need to link against indielib in your project somehow. Maybe this would help, (sorry I just throw first thing returned from google search, which has some meaning to me): http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/

SerhiiYashchuk commented 10 years ago

I found how to link to the library but I have to select the lib file. Have no idea where it is.

SerhiiYashchuk commented 10 years ago

Or can you tell me the easiest way to build my project without any IDE?

DarthMike commented 10 years ago

Regarding of where the lib file is, you will see it when you make: autoreconf sudo ./configure --prefix=/home/michael/indielib/IndieLib make clean all

To build indielib

It generally should be in /usr/local/lib/ after you built and installed indielib in your system

DarthMike commented 10 years ago

The easiest way is whatever is more comfortable for you :)

makefiles can be 'easier', but if you will start to hack a bigger project they become a hassle. so you can stick with Code::Blocks. Problem is we don't support it directly. We want to make CMake a priority, so anybody could choose to which IDE work using CMake to generate project files. Will come in due time ...

SerhiiYashchuk commented 10 years ago

There is no IndieLib in /usr/local/lib. I guess there were some errors in building it. Gonna check it out tomorrow.

SerhiiYashchuk commented 10 years ago

Ok. There were some problems with building IndieLib. After doing 'autoreconf' I had to do next: sudo make sudo make install prefix=/usr/local make clean all

After this commands I finally have libIndieLib in my /usr/local/lib. Gonna try to build a project.

SerhiiYashchuk commented 10 years ago

Tried to build project. Linked it to IndieLib. Then I had to link FreeImage, GLEW and SDL. Now I get errors about undefined reference to OpenGL functions.

DarthMike commented 10 years ago

Yes this is not totally correct on our side, we will fix it. You should not need to link against dependencies again in the app using indielib.

Just add gl to the linked libs, should be in your system already.

Glad you could advance further with the problem.

SerhiiYashchuk commented 10 years ago

Actualy I need to link dependencies, because there is the same problem with them - undefined reference. The only problem left is to find GL libs. Couldn't find them.

M-F-K commented 10 years ago

I think it's the Glew dependencies. If you take a look under the Linux part in the wiki, they are mentioned : http://indielib.com/wiki/index.php?title=Building_IndieLib

DarthMike commented 10 years ago

@Sergey-Yaschuk Did you suceed? Can we close this issue?

SerhiiYashchuk commented 10 years ago

Yeah. You can close it. Thanks for help.