Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - imdumb

Pages: [1]
1
General / SFML with cmake linker error? (OSX)
« on: April 13, 2021, 05:55:43 pm »
So I'm having this problem where if I try to compile the code with cmake on my mac, it throws an error that it can't load some resources.

Code: [Select]
[100%] Linking CXX executable bird
Undefined symbols for architecture x86_64:
  "__ZN2sf4Font12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", referenced from:
      __ZN13ResourceCache16loadFontResourceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_ in libBird_core.a(ResourceCache.cpp.o)
  "__ZN2sf6StringC1EPKcRKSt6locale", referenced from:
      __ZN9__gnu_cxx13new_allocatorIN2sf12RenderWindowEE9constructIS2_JNS1_9VideoModeERA11_KcNS1_5Style9._anon_74ERNS1_15ContextSettingsEEEEvPT_DpOT0_ in libBird_core.a(Game.cpp.o)
  "__ZN2sf6StringC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6locale", referenced from:
      __ZN19PlayingMenuActivity6updateERKf in libBird_core.a(PlayingMenuActivity.cpp.o)
      __ZN6Button9setStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE in libBird_core.a(Button.cpp.o)
  "__ZN2sf7Texture12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_4RectIiEE", referenced from:
      __ZN13ResourceCache19loadTextureResourceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_ in libBird_core.a(ResourceCache.cpp.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [bird] Error 1
make[1]: *** [CMakeFiles/bird.dir/all] Error 2
make: *** [all] Error 2

The code works on Windows and Linux so I don't think its an issue with the code, but with how I've linked stuff.

I think the difference is in my CMakeLists.txt file. Before it was using xcode's gcc to compile (and it would not compile) and so I changed it by changing these lines.

Code: [Select]
###########################
# CMake Build Environment #
###########################
#
# You can set the following Environment variables:
#
# CMAKE_MODULE_PATH to the search path for cmake modules (e.g., SFML.cmake)
# CMAKE_BUILD_TYPE to override the default build type. Valid options are 'release', 'profile' and 'debug'
#
#########################################


set(CMAKE_C_COMPILER "gcc-10")
set(CMAKE_CXX_COMPILER "g++-10")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set(CMAKE_CXX_STANDARD 11)



Any help would be appreciated!

Pages: [1]
anything