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

Bug #909454 reported by Neil Tan on 2011-12-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stratagus
Fix Released
Undecided
Pali

Bug Description

-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::for_each(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 to `jpeg_read_scanlines'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsDoTransform'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsErrorAction'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsCreateRGBProfile'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_start_decompress'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsFreeGamma'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_destroy_decompress'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_std_error'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_CreateDecompress'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_has_multiple_scans'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsOpenProfileFromFile'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsCloseProfile'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_input_complete'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_read_header'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_destroy_compress'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_finish_decompress'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_resync_to_restart'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsDeleteTransform'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsCreateTransform'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_finish_output'
/usr/local/lib/libmng.so.3.1: undefined reference to `jpeg_start_output'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsBuildGamma'
/usr/local/lib/libmng.so.3.1: undefined reference to `cmsWhitePointFromTemp'
collect2: ld returned 1 exit status
gmake[2]: *** [stratagus] Error 1
gmake[1]: *** [CMakeFiles/stratagus.dir/all] Error 2
gmake: *** [all] Error 2

Related branches

Neil Tan (emtneutrino) wrote :
Pali (pali) wrote :

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...

Changed in stratagus:
status: New → In Progress
assignee: nobody → Pali (pali)
tags: added: patch
Neil Tan (emtneutrino) wrote :

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.

Pali (pali) wrote :

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?

Pali (pali) wrote :

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

Changed in stratagus:
status: In Progress → Fix Committed
Neil Tan (emtneutrino) wrote :

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.

Pali (pali) wrote :

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.

Pali (pali) on 2012-04-19
Changed in stratagus:
milestone: none → 2.2.7
Pali (pali) on 2012-08-20
Changed in stratagus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers