Arx Libertatis Bug Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report #517  -  problem finding libs to link wicth installed through MacPorts (Building on Mac OS X)
Posted Jul 13, 2013 - updated Jul 14, 2013   Shortlink: http://arx.vg/517
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
icon_info.png This issue has been closed with status "Fixed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Fixed
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     xanm
  • Owned by
    Not owned by anyone
  • Estimated time
    Not estimated
  • Category
    Not determined
  • Resolution
    RESOLVED
  • Priority
    Not determined
  • Reproducability
    Not determined
  • Severity
    Not determined
  • Targetted for
    icon_milestones.png Not determined
  • OS
    icon_customdatatype.png Not determined
  • Architecture
    icon_customdatatype.png Not determined
  • Fixed in
    icon_customdatatype.png Arx Libertatis 1.1
Issue description
  1. [ 91%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptedItem.cpp.o
  2. [ 91%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptedLang.cpp.o
  3. [ 92%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptedNPC.cpp.o
  4. [ 93%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptedPlayer.cpp.o
  5. [ 93%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptedVariable.cpp.o
  6. [ 94%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptEvent.cpp.o
  7. [ 94%] Building CXX object CMakeFiles/arx.dir/src/script/ScriptUtils.cpp.o
  8. [ 95%] Building CXX object CMakeFiles/arx.dir/src/window/RenderWindow.cpp.o
  9. [ 95%] Building CXX object CMakeFiles/arx.dir/src/window/Window.cpp.o
  10. [ 96%] Building CXX object CMakeFiles/arx.dir/src/window/SDLWindow.cpp.o
  11. [ 97%] Building CXX object CMakeFiles/arx.dir/core/Version.cpp.o
  12. Linking CXX executable arx
  13. ld: library not found for -lSDLmain
  14. clang: error: linker command failed with exit code 1 (use -v to see invocation)
  15. make[2]: *** [arx] Error 1
  16. make[1]: *** [CMakeFiles/arx.dir/all] Error 2
  17. make: *** [all] Error 2


solved by adding
  1. # Add MacPorts
  2. INCLUDE_DIRECTORIES(/opt/local/include)
  3. LINK_DIRECTORIES(/opt/local/lib)


in CMakeList.txt
Steps to reproduce this issue
Nothing entered.

#2
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
Jul 13, 15:46
Just hardcoding these paths in CMakeLists.txt is not the solution.

Is the INCLUDE_DIRECTORIES(/opt/local/include) really needed? The include directory for SDL headers should already have been found by SDL as ${SDL_INCLUDE_DIR}. Do you perhaps have have two SDL intallations and the one CMake finds doesn't have SDL_main.h. What happens if you replace #include <SDL_main.h> with #include <SDL.h> in src/core/Startup.cpp - or does that just bring back Crash report 514 - Crash on Mac OS X at start?

As for LINK_DIRECTORIES(/opt/local/lib), the FindSDL CMake module should also find the full path to the SDLmain library. However it seems we for it to link to SDLmain on OS X, which is most likely wrong, at least without first using find_library. What happends if you remove the list(APPEND SDL_LIBRARIES "SDLmain") line in CMakeLists.txt?

The comments in FindSDL.cmake have this to say:
  1. # The Cocoa framework must be linked into SDL because SDL is Cocoa based.
  2. # Remember that the OS X framework version expects you to drop in
  3. # SDLmain.h and SDLmain.m directly into your project.
  4. # (Cocoa link moved to bottom of this script.)


It seems that SDL for OS X is distributed in two variants - the official framework version that requires projects to manually include SDL_main.h and SDL_main.m in their sources (hey, SDL devs, who though this was an acceptable solution) and the macports/whatever version that provides libSDLmain.h.

So our CMakeLists.txt at this point works with the non-framework version, but not with the .framework version -- and it also breaks if both are installed :S

Is there a way we can fix this for the .framwework version without including SDL_main.m in our source tree? Is there an SDL_main.m in the SDL.framework and (how) can we tell CMake to use it? I really don't know much about OS X frameworks.

Thankfully it looks like SDLmain is gone in SDL 2.0 (1), so this will fix itself when we move to that.

(1) http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-November/086414.html
#3
icon_reply.pngReply
Comment posted by
 xanm
icon_reply.pngJul 13, 19:44, in reply to comment #2
sorry INCLUDE_DIRECTORIES(/opt/local/include) i added by accident, but without LINK_DIRECTORIES(/opt/local/lib) the same error i posted

cake output:

  1. MacBook-Pro-Admin:build admin$ cmake ..
  2. -- The C compiler identification is GNU 4.2.1
  3. -- The CXX compiler identification is Clang 4.1.0
  4. -- Checking whether C compiler has -isysroot
  5. -- Checking whether C compiler has -isysroot - yes
  6. -- Checking whether C compiler supports OSX deployment target flag
  7. -- Checking whether C compiler supports OSX deployment target flag - yes
  8. -- Check for working C compiler: /usr/bin/gcc
  9. -- Check for working C compiler: /usr/bin/gcc -- works
  10. -- Detecting C compiler ABI info
  11. -- Detecting C compiler ABI info - done
  12. -- Check for working CXX compiler: /usr/bin/c++
  13. -- Check for working CXX compiler: /usr/bin/c++ -- works
  14. -- Detecting CXX compiler ABI info
  15. -- Detecting CXX compiler ABI info - done
  16. -- Checking compiler flag: -Wall
  17. -- Checking compiler flag: -Wextra
  18. -- Checking compiler flag: -Wformat=2
  19. -- Checking compiler flag: -Wundef
  20. -- Checking compiler flag: -Wpointer-arith
  21. -- Checking compiler flag: -Wcast-qual
  22. -- Checking compiler flag: -Woverloaded-virtual
  23. -- Checking compiler flag: -Wlogical-op - unsupported (warning)
  24. -- Checking compiler flag: -Woverflow
  25. -- Checking compiler flag: -Wliteral-conversion
  26. -- Checking compiler flag: -Wshift-overflow
  27. -- Checking compiler flag: -Wbool-conversions
  28. -- Checking compiler flag: -Wno-uninitialized
  29. -- Checking compiler flag: -Wno-constant-logical-operand
  30. -- Checking compiler flag: -Wno-undef
  31. -- Checking compiler flag: -g2
  32. -- Found PythonInterp: /usr/bin/python (found version "2.7.2")
  33. -- Looking for include file pthread.h
  34. -- Looking for include file pthread.h - found
  35. -- Looking for pthread_create
  36. -- Looking for pthread_create - found
  37. -- Found Threads: TRUE
  38. -- Found Freetype: /opt/local/lib/libfreetype.dylib (found version "2.4.10")
  39. -- Checking Freetype: /opt/local/lib/libfreetype.dylib
  40. -- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.5")
  41. -- Checking ZLIB: /usr/lib/libz.dylib
  42. -- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
  43. -- checking for module 'glew'
  44. -- found glew, version 1.9.0
  45. -- Found GLEW: /opt/local/lib/libGLEW.dylib
  46. -- Checking OpenGL: /System/Library/Frameworks/OpenGL.framework
  47. -- Checking GLEW: /opt/local/lib/libGLEW.dylib
  48. -- Found OpenAL: /System/Library/Frameworks/OpenAL.framework (Required is at least version "1.1")
  49. -- Could NOT find OpenALEFX (missing: OPENAL_EFX_INCLUDE_DIR)
  50. -- Checking OpenAL: /System/Library/Frameworks/OpenAL.framework
  51. -- Found SDL: /opt/local/lib/libSDLmain.a;/opt/local/lib/libSDL.dylib;-framework Cocoa (Required is at least version "1.2")
  52. -- Checking SDL: /opt/local/lib/libSDLmain.a;/opt/local/lib/libSDL.dylib;-framework Cocoa
  53. -- Boost version: 1.52.0
  54. -- Found Doxygen: /opt/local/bin/doxygen (found version "1.8.1.1")
  55. -- Checking compiler flag: -std=c++11
  56. -- Checking compiler flag: -fvisibility=hidden
  57. -- Checking compiler flag: -fvisibility-inlines-hidden
  58. -- Checking compiler feature: __builtin_trap
  59. -- Checking compiler feature: __attribute__((format(printf, i, j)))
  60. -- Looking for nanosleep
  61. -- Looking for nanosleep - found
  62. -- Looking for pthread_setname_np
  63. -- Looking for pthread_setname_np - found
  64. -- Looking for prctl
  65. -- Looking for prctl - not found.
  66. -- Looking for uname
  67. -- Looking for uname - found
  68. -- Looking for getrusage
  69. -- Looking for getrusage - found
  70. -- Looking for popen
  71. -- Looking for popen - found
  72. -- Looking for pclose
  73. -- Looking for pclose - found
  74. -- Looking for getexecname
  75. -- Looking for getexecname - not found.
  76. -- Looking for setenv
  77. -- Looking for setenv - found
  78. -- Looking for clock_gettime
  79. -- Looking for clock_gettime - not found.
  80. -- Looking for 3 include files mach/clock.h, ..., mach/mach_host.h
  81. -- Looking for 3 include files mach/clock.h, ..., mach/mach_host.h - found
  82. -- Looking for wordexp.h
  83. -- Looking for wordexp.h - found
  84. -- Looking for fork
  85. -- Looking for fork - found
  86. -- Looking for readlink
  87. -- Looking for readlink - found
  88. -- Looking for dup2
  89. -- Looking for dup2 - found
  90. -- Looking for execl
  91. -- Looking for execl - found
  92. -- Looking for execlp
  93. -- Looking for execlp - found
  94. -- Looking for isatty
  95. -- Looking for isatty - found
  96. -- Looking for sched_getscheduler
  97. -- Looking for sched_getscheduler - not found.
  98. -- Looking for kill
  99. -- Looking for kill - found
  100. -- Looking for backtrace
  101. -- Looking for backtrace - found
  102. -- Looking for sys/types.h
  103. -- Looking for sys/types.h - found
  104. -- Looking for getpid
  105. -- Looking for getpid - found
  106. -- Looking for sysconf
  107. -- Looking for sysconf - found
  108. -- Looking for sigaction
  109. -- Looking for sigaction - found
  110. -- Looking for sysctl
  111. -- Looking for sysctl - found
  112. -- Looking for sys/stat.h
  113. -- Looking for sys/stat.h - found
  114. -- Looking for sys/errno.h
  115. -- Looking for sys/errno.h - found
  116. -- Looking for dirent.h
  117. -- Looking for dirent.h - found
  118. -- Looking for readdir_r
  119. -- Looking for readdir_r - found
  120. -- Looking for getcwd
  121. -- Looking for getcwd - found
  122. -- Looking for fpathconf
  123. -- Looking for fpathconf - found
  124. -- Looking for pathconf
  125. -- Looking for pathconf - found
  126. -- Looking for _PC_NAME_MAX
  127. -- Looking for _PC_NAME_MAX - found
  128. -- Looking for _PC_CASE_SENSITIVE
  129. -- Looking for _PC_CASE_SENSITIVE - found
  130. -- Looking for dirfd
  131. -- Looking for dirfd - found
  132. -- Looking for fstatat
  133. -- Looking for fstatat - not found.
  134. -- Looking for NAME_MAX
  135. -- Looking for NAME_MAX - not found.
  136.  
  137. Configuration:
  138. - Build type: Release
  139. - Filesystem backend: POSIX
  140. - Renderer: OpenGL
  141. - Audio backend: OpenAL
  142. - Input backend: SDL
  143. - Windowing: SDL
  144. - Crash handler: (none)
  145. - Crash reporter: disabled
  146. - Tools: enabled
  147.  
  148. -- Configuring done
  149. -- Generating done
  150. -- Build files have been written to: /Users/admin/Documents/workspace/ArxLibertatis/build


looks like cmake found it
  1. -- Found SDL: /opt/local/lib/libSDLmain.a;/opt/local/lib/libSDL.dylib;-framework Cocoa (Required is at least version "1.2")
  2. -- Checking SDL: /opt/local/lib/libSDLmain.a;/opt/local/lib/libSDL.dylib;-framework Cocoa


but compiler still cant find it
#4
icon_reply.pngReply
Comment posted by
 xanm
icon_reply.pngJul 13, 19:58, in reply to comment #3
when i remove list(APPEND SDL_LIBRARIES "SDLmain") all is fine
#6
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
icon_reply.pngJul 14, 00:09, in reply to comment #4
Thanks for checking.

I removed the offending code from CMakeLists.txt - is everything working OK now?

Linking will probably still not work with the .framework version, but it's probably best to just wait for SDL 2 to fix that as I have no way to test it.
#8
icon_reply.pngReply
Comment posted by
 xanm
icon_reply.pngJul 14, 07:28, in reply to comment #6
Yes, everything is ok now i built right from the repo and all work fine

#9
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
Jul 14, 11:38
Ok, thanks for checking.

The issue was updated with the following change(s):
  • This issue has been closed
  • The status has been updated, from New to Fixed.
  • The resolution has been updated, from Not determined to RESOLVED.
  • This issue's progression has been updated to 100 percent completed.