#

## ClanLib 0.8 FAQ

Frequently Asked Questions about the ClanLib Library:

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 at clanlib-user@clanlib.org.

### Compiling under Linux

Question: | After compiling ClanLib and trying to link anything with it, I get a linker error complaining about glX: /usr/local/lib/libclanGL.so: undefined reference to `glXGetProcAddress`
Answer: | 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.

Question: | How can I detect ClanLib from within a configure script?
Question: | How do I use `pkg-config?`
Answer: | ClanLib-0.8 uses `pkg-config` to handle the issue of maintaining compiler and library flags needed for compilation. ClanLib-0.8 also installes its include files into `${prefix}/include/ClanLib-0.8/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.8 clanDisplay-0.8 clanGL-0.8` 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.8.0" PKG_CHECK_MODULES(YOURPROG, [ clanCore-0.8 >= $REQUIRED_CLANLIB_VERSION clanApp-0.8 >= $REQUIRED_CLANLIB_VERSION clanDisplay-0.8 >= $REQUIRED_CLANLIB_VERSION clanGL-0.8 >= $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.

Question: | Why does `pkg-config` fails to find ClanLib?
Answer: | 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/

Question: | Why does ClanLib install its includes into `${prefix}/include/ClanLib-0.8/ClanLib/?`
Answer: | 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.8 -I/usr/local/include/ClanLib-0.8/

Question: | How can I install and use ClanLib when I am not root?
Question: | How can I keep multiple version of ClanLib at the same time?
Answer: | 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.8-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.8-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.

Question: | When I try to compile ClanLib, I get errors regarding that try, catch and throw are reserved C++ keywords.
Question: | My C++ compiler wants exceptions to be enabled with -fhandle-exceptions.
Question: | I get an "Internal compiler error" message from my C++ compiler.
Answer: | Try upgrading your compiler to a newer version.

Question: | When compiling it complains that it cannot open shared object libclanCore... error in loading shared libraries: libclanCore.so.0: cannot open shared object file: No such file or directory
Answer: | 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.

Question: | I'm using PGCC, and I get error while compiling a file called virtch.c.
Question: | I'm using Mandrake 6.x or earlier, and I get error while compiling a file called virtch.c.
Answer: | Open Setup/Unix/makefile.conf, search for -O3 and replace it with -O6.

Question: | I'm using SuSE and am getting warnings about multiple common of... obj/Input.o: warning: multiple common of 'CL_InputAxis type_info node' /usr/local/lib/libclan.so: warning: previous common is here
Answer: | 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...

Question: | I use Slack 7 and getting errors about cannot specify -o with -c or -S... Sources/Core/Display/Generic/cliprect.cpp g++: cannot specify -o with -c or -S and multiple compilations make: *** [Libs/Intermediate/cliprect.o] Error 1
Answer: | 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).

### Compiling under Windows

Question: | I try to compile an app using ClanLib under Visual C++ and it gets unresolved external symbol _main... Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Answer: | 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.

Question: | I try to compile an app using ClanLib under Visual C++ and it gets unresolved external symbol _WinMain... Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Answer: | Link clanApp.lib (for release) and clanAppd.lib (for debug) into your project.

Question: | When I compile ClanLib, I get messages about "Directory already exists"
Question: | When I compile ClanLib, I get warnings about __NULL_IMPORT_DESCRIPTOR... 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
Answer: | Ignore these warnings, they are non-fatal.

Question: | I get errors about conflicts with the library "LIBCMT" LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
Question: | I just upgraded to VS7 now all my projects wont compile , even the examples , I get a link error: ExampleGUIGL error LNK2001: unresolved external symbol "void __cdecl std::_Xlen(void)" (?_Xlen@std@@YAXXZ)
Answer: | 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.

Question: | How can I compile ClanLib under Win32 using an other compiler than Visual C++?
Question: | Can I use the windows binaries with another compiler than Visual C++?
Answer: | 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.

Question: | What is the configure app?
Answer: | 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.

### Running under Windows

Question: | What is required to run ClanLib games under Windows?
Answer: | Nothing except your game, as all libraries will be statically linked into your game.

Question: | How do I get a console window under Windows to print debug information?
Answer: | You can add this code to your app: // Create a console window for text-output if not available CL_ConsoleWindow console("Console"); console.redirect_stdio(); .... rest of app .... // 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

### Programming issues

Question: | When I try to run my ClanLib program, it tells me there is no global CL_ClanApplication instance... ClanLib: No global CL_ClanApplication instance!!!
Answer: | The CL_ClanApplication class must be inherited by all ClanLib applications. In your application you must create a class inheriting CL_ClanApplication, make a global instance of it, and fill in the main() function.

Question: | I'm getting an error while using the resources. It says: Unknown type 'surface' declared for resource 'Graphics/maptiles'
Answer: | 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().

### CVS

Question: | I run WinCVS, and it exits with code 0... *****CVS exited normally with code 0****** What do I do wrong ?
Answer: | Nothing, this simply means everything went OK.

Questions or comments, write to the ClanLib mailing list.