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

Author Topic: CMake doesn't link with SFML libaries  (Read 11127 times)

0 Members and 1 Guest are viewing this topic.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
CMake doesn't link with SFML libaries
« on: September 12, 2012, 04:53:59 pm »
Hi

I make a small project to compile projects using CMake. But when i will link the libraries of SFML i got the error:

Quote
MacBook-Pro-de-Paulo-Coutinho-2:build paulo$ ./build.sh
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found SFML: /usr/local/include
CMake Error at CMakeLists.txt:19 (target_link_libraries):
  Cannot specify link libraries for target
  "/usr/local/lib/libsfml-system.dylib" which is not built by this project.


-- Configuring incomplete, errors occurred!
make: *** No targets specified and no makefile found.  Stop.

The project is located here:

https://github.com/prsolucoes/sfml-cmake

To build, you need enter in "build" directory and call "sh build.sh" and to clear temp. files, call in "build" directory "sh clean.sh".

The libraries was installed using default cmake files of SFML package.

Thans for any help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CMake doesn't link with SFML libaries
« Reply #1 on: September 12, 2012, 05:03:24 pm »
You use the ${EXECUTABLE_NAME} variable without defining it. I guess you wanted to use ${PROJECT_NAME} instead.
Laurent Gomila - SFML developer

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #2 on: September 12, 2012, 05:05:14 pm »
Same problem.

The message is not related with it :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CMake doesn't link with SFML libaries
« Reply #3 on: September 12, 2012, 05:09:34 pm »
Really? The error with target_link_libraries at line 19 was definitely caused by that.
Laurent Gomila - SFML developer

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #4 on: September 12, 2012, 05:10:59 pm »
I change the variable name, but not solved. Changes was commited to GITHUB. You can see. The same error message  was showed.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #5 on: September 12, 2012, 05:12:36 pm »
Sorry.

Now the message is:

Quote
Found SFML: /usr/local/include
CMake Error at CMakeLists.txt:19 (target_link_libraries):
  Cannot specify link libraries for target "sfml-cmake" which is not built by
  this project.


-- Configuring incomplete, errors occurred!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CMake doesn't link with SFML libaries
« Reply #6 on: September 12, 2012, 05:14:54 pm »
You must define the target (add_executable) before using it in the target_link_libraries.

You should read more CMake doc and examples before trying to write your own build files, this is really basic stuff.
Laurent Gomila - SFML developer

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #7 on: September 12, 2012, 05:23:56 pm »
Ok man.

Thanks for your help. Im learning cmake, but i dont read about commands ordering, i dont know about it, but 99%of the file was correct.

But it is compiling now.

But i want do another think. I want link not with system library. I want distribute the project with the compiled libraries for win32/mac/linux as i do with the project:

https://github.com/prsolucoes/sfml-project

I want now learn how to link with the libraries in "library/mac" and "library/win32" using cmake and include the include files under "library" path too.

Can you help me?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: CMake doesn't link with SFML libaries
« Reply #8 on: September 12, 2012, 05:31:00 pm »
I want now learn how to link with the libraries in "library/mac" and "library/win32" using cmake and include the include files under "library" path too.

Can you help me?
I suggest you take a look at other CMake files, learn from them and keep reading the documentation (e.g. SFGUI or Thor, keep in mind those are libraries not executable^s).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #9 on: September 12, 2012, 06:49:26 pm »
Im not an expert of CMake but i didn't found any example that dont use the "FindSFML". I dont use it.

I already have the includes and libraries in my project, i want link with this. As you see in github "library" path.

But is too hard find anything about it.


prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #10 on: September 12, 2012, 07:10:27 pm »
Ok.

Now i delete "libs" and "includes" of SFML from my system and im using the libraries from project.

It is compiling with success now.

But when i will open the binary, i got error and it close. I think that the libraries need be copied/bundle with binary.

Can you help me? The changes are commited to github.

With this project and the target of this project is clone the repository and compile the project without need lose time with libraries, it will turn easy the gamers life. You need focus on the code, not arch.

Can you help me?


prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #11 on: September 12, 2012, 07:26:02 pm »
The error receive is what i think:

Quote
MacBook-Pro-de-Paulo-Coutinho-2:build paulo$ ./sfml-project.app/Contents/MacOS/sfml-project
dyld: Library not loaded: @executable_path/../Frameworks/libsfml-system.2.dylib
  Referenced from: /Users/paulo/Pessoal/workspaces/qt/sfml-cmake/build/./sfml-project.app/Contents/MacOS/sfml-project
  Reason: image not found
Trace/BPT trap


prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #12 on: September 12, 2012, 08:14:05 pm »
Now, im copying the libraries to framework directory. But only the libraries without ".2" and ".2.0", example:

libsfml-audio.2.0.dylib (not copied)
libsfml-audio.2.dylib (not copied)
libsfml-audio.dylib (copied)

Result:

Quote
Scanning dependencies of target sfml-project
[100%] Building CXX object CMakeFiles/sfml-project.dir/main.cpp.o
Linking CXX executable sfml-project.app/Contents/MacOS/sfml-project
Copying OS X content sfml-project.app/Contents/Frameworks/libsfml-audio.dylib
Copying OS X content sfml-project.app/Contents/Frameworks/libsfml-graphics.dylib
Copying OS X content sfml-project.app/Contents/Frameworks/libsfml-network.dylib
Copying OS X content sfml-project.app/Contents/Frameworks/libsfml-system.dylib
Copying OS X content sfml-project.app/Contents/Frameworks/libsfml-window.dylib
[100%] Built target sfml-project


Please, help me :(

The changes are commited on actual state

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #13 on: September 12, 2012, 08:49:10 pm »
I made a poor implementation of copy required files and the project is working now.

If anyone want help make it better and more "cmake" style, please contact me or send message here with suggestions.

Ty.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: CMake doesn't link with SFML libaries
« Reply #14 on: September 14, 2012, 05:38:26 am »
Hi,

I have a small problem on compile in two different macs.

In my "work mac" it is compiling without problem:

Quote
MacBook-Pro-de-Paulo-Coutinho-2:build paulo$ ./rebuild.sh
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found SFML: /Users/paulo/Pessoal/workspaces/qt/sfml-cmake/library/sfml/mac/include
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/paulo/Pessoal/workspaces/qt/sfml-cmake/build
Scanning dependencies of target sfml-project
[ 33%] Building CXX object CMakeFiles/sfml-project.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/sfml-project.dir/sf_v8.cpp.o
[100%] Building CXX object CMakeFiles/sfml-project.dir/v8wrap.cpp.o
Linking CXX executable sfml-project.app/Contents/MacOS/sfml-project
[100%] Built target sfml-project

In my "home mac" the library SNDFILE is not working:

Quote
server:build paulo$ ./rebuild.sh
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is GNU 4.2.1
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Found SFML: /Users/paulo/Pessoal/workspaces/qt/sfml-cmake/library/sfml/mac/include
CMake Error at /Applications/CMake 2.8-9.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
  Could NOT find SNDFILE (missing: SNDFILE_LIBRARY)
Call Stack (most recent call first):
  /Applications/CMake 2.8-9.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
  build/cmake/modules/FindSNDFILE.cmake:20 (find_package_handle_standard_args)
  CMakeLists.txt:44 (find_package)


-- Configuring incomplete, errors occurred!
make: *** No targets specified and no makefile found.  Stop.

I see one difference in compiler name, but i dont know if is it. In the cmake project file i forced both to use "g++".

Can anyone help me?

Project is here:
https://github.com/prsolucoes/sfml-cmake

 

anything