Wargus / stratagus

The Stratagus strategy game engine
GNU General Public License v2.0
628 stars 120 forks source link

stratagus 2.2.6 not compiling on OpenBSD 5.0 GENERIC.MP#59 i386 - patches included #52

Closed timfel closed 8 years ago

timfel commented 8 years ago

-need to add "add_definitions(-D__unix)" for BSD case in CMakeLists.txt to correct error below In file included from /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/include/stratagus.h:149, from /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/metaserver/cmd.cpp:40: /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/include/util.h:44:22: error: winsock2.h: No such file or directory /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/include/util.h:45:21: error: windows.h: No such file or directory

-need to remove "&" from template function "for_each" in unit_cache.h to correct error below In file included from /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/ai/ai_building.cpp:44: /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/ai/ai_local.h: In member function 'void AiForce::Reset(bool)': /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/ai/ai_local.h:140: error: no matching function for call to 'CUnitCache::foreach(void ()(CUnit))' /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/include/unit_cache.h:135: note: candidates are: void CUnitCache::for_each(_T&) [with T = void ()(CUnit)] gmake[2]: * [CMakeFiles/stratagus.dir/src/ai/ai_building.cpp.o] Error 1 gmake[1]: * [CMakeFiles/stratagus.dir/all] Error 2 gmake: *\ [all] Error 2

-need to add "#if defined (USE_BSD)" case in util.cpp to correct error below /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/stratagus/util.cpp: In constructor 'CMutex::CMutex()': /home/neutrino/wrk/stratagus/stratagus_2.2.6.orig/src/stratagus/util.cpp:493: error: 'pthread_mutexattr_setpshared' was not declared in this scope gmake[2]: * [CMakeFiles/stratagus.dir/src/stratagus/util.cpp.o] Error 1 gmake[1]: * [CMakeFiles/stratagus.dir/all] Error 2 gmake: *\ [all] Error 2

-need to add "/usr/local/lib/liblcms.so.2.0" and "/usr/local/lib/libjpeg.so.64.0" to CMakeLists.txt to correct error below /usr/local/lib/libmng.so.3.1: undefined reference to cmsOpenProfileFromMem' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_read_scanlines' /usr/local/lib/libmng.so.3.1: undefined reference to cmsDoTransform' /usr/local/lib/libmng.so.3.1: undefined reference tocmsErrorAction' /usr/local/lib/libmng.so.3.1: undefined reference to cmsCreateRGBProfile' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_start_decompress' /usr/local/lib/libmng.so.3.1: undefined reference to cmsFreeGamma' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_destroy_decompress' /usr/local/lib/libmng.so.3.1: undefined reference to jpeg_std_error' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_CreateDecompress' /usr/local/lib/libmng.so.3.1: undefined reference to jpeg_has_multiple_scans' /usr/local/lib/libmng.so.3.1: undefined reference tocmsOpenProfileFromFile' /usr/local/lib/libmng.so.3.1: undefined reference to cmsCloseProfile' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_input_complete' /usr/local/lib/libmng.so.3.1: undefined reference to jpeg_read_header' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_destroy_compress' /usr/local/lib/libmng.so.3.1: undefined reference to jpeg_finish_decompress' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_resync_to_restart' /usr/local/lib/libmng.so.3.1: undefined reference to cmsDeleteTransform' /usr/local/lib/libmng.so.3.1: undefined reference tocmsCreateTransform' /usr/local/lib/libmng.so.3.1: undefined reference to jpeg_finish_output' /usr/local/lib/libmng.so.3.1: undefined reference tojpeg_start_output' /usr/local/lib/libmng.so.3.1: undefined reference to cmsBuildGamma' /usr/local/lib/libmng.so.3.1: undefined reference tocmsWhitePointFromTemp' collect2: ld returned 1 exit status gmake[2]: * [stratagus] Error 1 gmake[1]: * [CMakeFiles/stratagus.dir/all] Error 2 gmake: *\ [all] Error 2


Imported from Launchpad using lp2gh.

timfel commented 8 years ago

(by emtneutrino)

timfel commented 8 years ago

(by pali) Thanks for patches!

util.cpp and unit_cache.h looks good. Also adding -D__unix for BSD is Ok. But problem is adding other local libraries for linking.

From your buildlog I see that external library libmng.so.3.1 depends on externals libraries liblcms.so.2.0 and libjpeg.so.64.0. This is platform specified dependency of external library which should be fixed in CMake (maybe cmake/modules/FindMNG.cmake?). I do not know how OpenBSD handling library dependences, but tested linux distributions do not have this problem.

Do you know any project/program which using CMake build systemm using MNG library and working fine on BSD? I think that this problem was in other projects too and maybe it is solved...

timfel commented 8 years ago

(by emtneutrino) Sorry, I don't know any other projects using CMake and MNG, but this project and stargus are the only one's I've really looked at in much detail. mplayer depends on libmng on OBSD, but I don't know if it uses CMake. I haven't checked.

By the way, I've also gotten startool from stargus to work properly on OBSD. I had to replace all the huffmann decompression code with stormlib's huffmann code which I had to modify from zezula.net. It was too hard to decipher the original startool code. It was segfaulting when decompressing wav files all the time. I can open a bug for stargus 2.2.5.5 and post the patches if you want. Let me know.

timfel commented 8 years ago

(by pali) Now I looked into MNG library and I see that MNG library depends on jpeg library and lcms library. MNG library calling jpeg and lcms functions so these dependences should be filled in MNG library in your system. Your error message sounds like mng library does not have these dependences in ELF library binary. Can you contact maintainer of package which providing mng support on your system about this problem?

timfel commented 8 years ago

(by pali) All patches (expect that for MNG library) was commited to bzr.

timfel commented 8 years ago

(by emtneutrino) When supplying compile options manually on the command line, you would have to specify -llcms to link to liblcms.so and -ljpeg to link to libjpeg.so for the calls in libmng.so to link to the proper object code. It is similar to the -lm link option which would link sin, cos, and tan function calls to the math library which is libm.so. From my experience with OBSD, you always have to specify -lm when linking trigonometry math functions. For example to compile a program using the trigonometry functions you would normally write "gcc -o program program.c -lm". I'm guessing the same has to be done for liblcms.so and libjpeg.so. The compile line would be something like "g++ -o stratagus stratagus.cpp -llcms -ljpeg -lm". If there is a way to make CMake add -llcms and -ljpeg to the LDFLAGS variable only for the BSD case, that would probably be the way to go.

timfel commented 8 years ago

(by pali) With sin, cos, tan and other mathematic functions you are right that you must compile app with -lm (because functions are in libm.so and not included in default libc.so).

But imagine this situation: You will create new library which will have one exported function and that function will use function sin from libm.so. That library must be linked with libm.so and if you will use this new library in app, you do not have to link your app with libm.so, because your app does not depend on libm.so but depends on that new library.

And this is same situation in Stratagus. Stratagus does not using JPEG and LCMS libraries. Only other external library (MNG) using JPEG and LCMS, so MNG should be linked with both JPEG and LCMS.

Becuse Stratagus not using JPEG or LCMS libraries, I think Stratagus should not be linked with that libraries. So I think this is not bug in Stratagus.

Contact maintainer of MNG library in your system and ask why is MNG library not linked with JPEG and LCMS.