This document tries to answer questions a user might have when installing and using ClanLib. Please make sure you read this before sending questions or bug reports to the maintainers.
If you find any errors or outdated information in this document, please let us know on our forum.
This is the FAQ section dedicated with compiling under Linux. Feel free to contribute and make it easier for anyone else that has a problem.
Download
Download the current sources from our Download page.
Configure
Configure clanlib
./configure --enable-clanDisplay --enable-clanGL --enable-clanGL1 --enable-clanSound \ --enable-clanDatabase --enable-clanSqlite --enable-clanRegExp --enable-clanNetwork \ --enable-clanGUI --enable-clanGDI --enable-clanMikMod --enable-clanVorbis
If you're missing libraries, use Synaptic or apt-get to install them.
Make
make
If you get any errors at this point, go to the forums and request help from there.
Install
sudo make install
By this point, everything should have been built and installed correctly. To test this, try compiling one of the examples. If it works, you're all set! If there's any issues, try asking on the forums for advice.
See #I get an "Internal compiler error" message from my C++ compiler
The OpenGL GLX headers and library files are out-of-sync on the machine. Typically when this happens, the headers are from XFree86/DRI, and the OpenGL library files are from Nvidia.
It looks like the Nvidia driver implements GLX 1.3 and the installer does not substitute the "default" XFree86-devel headers (which define GLX 1.4). Luckily the header files are included in /usr/share/doc/NVIDIA_GLX-1.0/.
In GLX 1.3 glXGetProcAddress is named glXGetProcAddressARB, causing a conflict here. To resolve the problem, make sure ClanLib is compiled with the same headers as the library files being used.
Looks Like
undefined reference to `__gcov_init' undefined reference to `__gcov_merge_add' make: *** Error 1
Effects
This problem happens when you compile ClanLib with profiling and then try to compile an application without it.
Solutions
"obj/Input.o: warning: multiple common of 'CL_InputAxis type_info node' /usr/local/lib/libclan.so: warning: previous common is here"
To get rid of those annoying "multiple common..." warnings edit /usr/lib/gcc-lib/i486-linux/egcs-???/specs:
*lib
-warn-common%{share....
should be:
*lib
%{share...
See #I get an "Internal compiler error" message from my C++ compiler
Try upgrading your compiler to a newer version.
Chances are you installed the ClanLib libraries into /usr/local/lib, but usr/local/lib isn't present in the /etc/ld.so.conf. You can choose to install in a directory that IS present in /etc/ld.so.conf or choose to add /usr/local/lib to /etc/ld.so.conf. Remember to run ldconfig as root afterwards.
See #I'm using Mandrake 6.x or earlier, and I get error while compiling a file called virtch.c.
Open Setup/Unix/makefile.conf, search for -O3 and replace it with -O6.
This problem looks like this:
Sources/Core/Display/Generic/cliprect.cpp g++: cannot specify -o with -c or -S and multiple compilations make: *** [Libs/Intermediate/cliprect.o] Error 1
The problem is that configure fails at detecting where X11 is installed. This means that Makefile.conf gets a faulty "-I -I" and an empty "-L". If you remove those in Makefile.conf, then your compile should preceed without problems. (Or better, modify configure to correctly locate X11, and send us a patch).
ClanLib-0.7 uses pkg-config to handle the issue of maintaining compiler and library flags needed for compilation. ClanLib-0.7 also installes its include files into ${prefix}/include/ClanLib-0.7/ClanLib/, so the normal way of just adding -lclanCore, etc. will not work. pkg-config simply outputs the compiler flags that are nedded for a given package, so usage is easy. To compile a simple test programm just do:
$ g++ yourprog.cpp -o yourprog `pkg-config --cflags --libs clanCore-0.7 clanDisplay-0.7 clanGL-0.7`
If you are using a configure script to configure the build process you can get the same thing done with the following macro:
REQUIRED_CLANLIB_VERSION="0.7.3" PKG_CHECK_MODULES(YOURPROG, [ clanCore-0.7 >= $REQUIRED_CLANLIB_VERSION clanApp-0.7 >= $REQUIRED_CLANLIB_VERSION clanDisplay-0.7 >= $REQUIRED_CLANLIB_VERSION clanGL-0.7 >= $REQUIRED_CLANLIB_VERSION ], []) AC_SUBST(YOURPROG_CFLAGS) AC_SUBST(YOURPROG_LIBS)
Replace REQUIRED_CLANLIB_VERSION by whatever minor version is required for you program and YOURPROG with whatever is the name of your application. The result of this macro will be that YOURPROG_LIBS and YOURPROG_CFLAGS get set to the values returned by pkg-config. If you also use automake you have to add a line like:
yourprog_CPPFLAGS = @PINGUS_CFLAGS@
to your Makefile.am.
See #How can I keep multiple version of ClanLib at the same time?
First of all, to install ClanLib in a different location you need to set another prefix, which is per default at /usr/local. To set another prefix just configure ClanLib like this:
./configure --prefix=/home/your_name/run/ClanLib-0.7-CVS-2003-08-16/
Once you have done that make install will install all ClanLib stuff into the given location. To make gcc and pkg-config recognize include files and libraries that are not in the standard locations you need to set a few extra variables:
export CLANLIB_PREFIX=/home/your_name/run/ClanLib-0.7-CVS-2003-08-16/ export PKG_CONFIG_PATH=$CLANLIB_PREFIX/lib/pkgconfig/ export LD_LIBRARY_PATH=$CLANLIB_PREFIX/lib/ export LD_RUN_PATH=$CLANLIB_PREFIX/lib/ export LIBRARY_PATH=$CLANLIB_PREFIX/lib/ export CPLUS_INCLUDE_PATH=$CLANLIB_PREFIX/include/ export C_INCLUDE_PATH=$CLANLIB_PREFIX/include/
Once you have set all the variables gcc and pkgconfig should find everything needed and compilation of other programms can be done just as normal.
By default pkg-config does not look in /usr/local/lib/pkg-config/. To fix this simply set the environment varible PKG_CONFIG_PATH as described in the pkg-config man page:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
While GNU/Linux systems provide versioned library files and so allow to have multiple libraries installed at the same time, they do not provide such a system for include files. So if the include files would go directly to ${prefix}/include/ClanLib/ there would be no way to have two ClanLibs (say an old stable one and the newest development version) installed at the same time. By installing the includes in a versioned subdirectory this problem is solved. To still being able to find the includes with there normal ClanLib/foobar.h names it is however needed to pass an include flag to the compiler, the include flag is returned by the pkg-config programm:
$ pkg-config --cflags clanCore-0.7 -I/usr/local/include/ClanLib-0.7/
This problem looks like this:
Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
You have to create a Win32 Application project and not a Win32 Console Application. Otherwise, add the linker option "/entry:WinMainCRTStartup" to your project options.
This problem looks like this:
Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Link clanApp.lib (for release) and clanAppd.lib (for debug) into your project.
See #When I compile ClanLib, I get warnings about __NULL_IMPORT_DESCRIPTOR.
This problem looks like this:
ddraw.lib(DDRAW.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in winmm.lib(WINMM.dll); second definition ignored dsound.lib(DSOUND.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in winmm.lib(WINMM.dll); second definition ignored dinput.lib(DINPUT.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in winmm.lib(WINMM.dll); second definition ignored wsock32.lib(WSOCK32.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in winmm.lib(WINMM.dll); second definition ignored
Ignore these warnings, they are non-fatal.
This problem looks like this:
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
See #I just upgraded to VS7 now all my projects wont compile.
FIXME: this question topic is too general
This problem looks like this:
ExampleGUIGL error LNK2001: unresolved external symbol "void __cdecl std::_Xlen(void)" (?_Xlen@std@@YAXXZ)
This is a warning from the linker telling you that not all your libraries (or the application itself) have been compiled with the same threading model. LIBCMT.lib is the C library used for the Multi-threadded model. LIBC.lib is the one used for the Single-threadded model.
Make sure that all libraries have built with the same settings, otherwise you will get this message. You find the settings for this in the Project Settings of each project.
In some cases it can be difficult to completely eliminate this warning. This particular happens in the context where you link debug versions with release versions of libraries. If eg. zlib.lib is built with the Multithreaded model, but clanCored.lib is built with Multithreaded debug model, then you could also get this warning. It is possible to workaround this problem by entering the project settings->link->input category, and write "libcmt" to the Ignore Libraries section.
Please be aware that some of the libraries ClanLib uses per default is built using an other threading model than the ClanLib libraries. Some of those use makefiles to build themself, making it more tricky to switch threading model. An easy way out of this problem is to download the precompiled Windows External Binaries we offer on our download page.
For more information about linking with the correct C run-time library, have a look at Microsoft's knowledge base article Q140584.
See #Can I use the windows binaries with another compiler than Visual C++?
ClanLib does not currently officially support anything but Microsoft Visual C++ under Windows. But it should be possible to use ClanLib with other compilers. Recently support for Borland C was added, but in an experimental state.
If people want to use another compiler together with ClanLib, notice that there are some things you need to be aware of:
1. You probably cannot use the win32 binaries. Because there is no standard on the symbol names used, it will be only Visual C++ 6.0 that those are guaranteed to work with.
2. You will have to make your own makefiles or projectfiles.
In the source package, there is a workspace called Configure.dsw. It produces the real ClanLib workspace and project files based on some questions asked in a MFC Wizard. This configure app should always be run after a ClanLib update, and of course when compiling ClanLib for the first time.
Nothing except your game, as all libraries will be statically linked into your game.
You can add this code to your app:
// Create a console window for text-output if not available CL_ConsoleWindow console("Console"); .... rest of app .... CL_Console::write_line("Hello %1 world.", "console") // cout won't work, use CL_Console ... // Display console close message and wait for a key console.display_close_message();
Otherwise, you can specify the following linker options for a standard Win32 Application project:
/entry:"WinMainCRTStartup" /subsystem:console
unknown type 'surface' means that you didn't initialise clanDisplay. The different resource types must be registered before trying to access the resource file, and this is done in eg. CL_SetupDisplay::init().