Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[raylib] build failure #15905

Closed
zipzit opened this issue Jan 27, 2021 · 18 comments · Fixed by #15935
Closed

[raylib] build failure #15905

zipzit opened this issue Jan 27, 2021 · 18 comments · Fixed by #15935
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@zipzit
Copy link

zipzit commented Jan 27, 2021

Host Environment

  • OS: [Ubuntu 20.04 Desktop] I'm running this in Virtualbox on a Windows10 machine.
  • Compiler: BCC for c99 9.3.0 (Using compilers C = /bin/c99-gcc)
  • Running VScode v1.52.1, with C/C++, CMake Tools and CodeLLDB extensions
  • cmake version 3.16.3
  • ./vcpkg version --> Vcpkg package management program version 2021-01-13-unknownhash

To Reproduce
Steps to reproduce the behavior:
./vcpkg install raylib
response:

The package raylib:x64-linux provides CMake targets:

    find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAYLIB_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${RAYLIB_LIBRARIES})

./vcpkg integrate install
response:

Applied user-wide integration for this vcpkg root.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/vagrant/Desktop/vcpkg/scripts/buildsystems/vcpkg.cmake"

Error appears in the development tooling immediately.

Failure logs
[build] /home/vagrant/Desktop/vscode_cpp_projects/9_vcpkg_raylib/main.cpp:23:10: fatal error: raylib.h: No such file or directory

Additional context
Ouch. On Unix box, the directory tree is: .../vcpkg/packages/raylib_x64-linux/include (where all the .h files are located.) Unfortunately, as I peek in the CMakeCache.txt file, everything is pointing at: .../vcpkg/packages/raylib_x64-linux/debug/include...

.../debug/... how did that get in there? The visible error is fatal error: raylib.h: No such file or directory

And I'm not comfortable enough with my CMake skills for a pull request on a fix within the raylib port. Its not clear to me on how this works. Its not clear to me on if the miss is in the intended structure or the directory path variables. At any rate those two things don't match each other.

Any hints as to how to fix this? many thanks.

@zipzit zipzit changed the title [<port name>] build failure [raylib] build failure Jan 27, 2021
@NancyLi1013 NancyLi1013 added the category:port-bug The issue is with a library, which is something the port should already support label Jan 28, 2021
@heretique
Copy link

Host Environment

OS: Windows10.
Compiler: MSVC 16.8.4 (64 bit)
Running VScode v1.52.1, with C/C++, CMake Tools and CodeLLDB extensions
cmake version 3.19.2
vcpkg version --> Vcpkg package management program version 2021-01-13-unknownhash

I don't know if this is the same or similar issue but if I try to add raylib to my project like it is recommended by vcpkg after installation

The package raylib:x64-windows provides CMake targets:

    find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAYLIB_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${RAYLIB_LIBRARIES})

I get a lot of unresolved external linker errors.
If I print the expected variables cmake_print_variables(RAYLIB_INCLUDE_DIRS RAYLIB_LIBRARIES), I get empty values:

1> [CMake] -- RAYLIB_INCLUDE_DIRS="" ; RAYLIB_LIBRARIES=""

Strange though, that it does find the includes when compiling.

@NancyLi1013
Copy link
Contributor

Hi @heretique and @zipzit

Thanks for posting this issue.

The current usage is not correct. The variables are from vcpkg-cmake-wrapper.cmake, which has been removed from portfile.cmake,

So the usage requires vcpkg-cmake-wrapper.cmake.

I also tries to use raylib-confg.cmake to build, it failed withfatal error LNK1181: cannot open input file 'raylib-NOTFOUND.obj'.

There are many errors in raylib-confg.cmake . I also noticed that upstream has planned to export targets for raylib, but there are still some work needed to be done.

@NancyLi1013
Copy link
Contributor

Could you please help test if the PR #15935 can build fine? @heretique and @zipzit

@zipzit
Copy link
Author

zipzit commented Jan 29, 2021

Will do. I need a little bit of help though. I don't understand totally how to get your pull request branch into my local repository. I thought it was:

$ git fetch
$ $ git remote add -f NancyLi1013 https://github.com/NancyLi1013/vcpkg/tree/dev/NancyLi/fix-raylib

Updating NancyLi1013
fatal: repository 'https://github.com/NancyLi1013/vcpkg/tree/dev/NancyLi/fix-raylib/' not found
error: Could not fetch NancyLi1013

How do I pull that branch? I know I can just make the same changes and test that, but now I'm really curious... I never did this before. many thx for your work here...

Hmm.. I went to https://github.com/NancyLi1013/vcpkg/tree/dev/NancyLi/fix-raylib and I realized that I could just clone that.
I deleted the entire vcpkg, and cloned yours. That totally worked.
$git clone https://github.com/NancyLi1013/vcpkg.git I can see your changes now.. give me a few minutes to test this..

@zipzit
Copy link
Author

zipzit commented Jan 29, 2021

Start with NancyLi1013 install
$  cd vcpkg
$  ./bootstrap-vcpkg.sh
$  ./vcpkg install raylib

-->

Total elapsed time: 2.056 min

The package raylib:x64-linux provides CMake targets:

    find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${raylib_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${raylib_LIBRARIES})

So one change I noticed here... in the above response, ${RAYLIB_INCLUDE_DIRS} went to ${raylib_INCLUDE_DIRS}, (capitalization) I made those changes to my CMakeLists.txt file

$  ./vcpkg integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/vagrant/Desktop/vcpkg/scripts/buildsystems/vcpkg.cmake"

I still see an error in VS code after I attempt CMake: Configure... It shows up in the PROBLEMS tab.
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):Could NOT find raylib (missing: raylib_LIBRARY)

If it helps I can upload my CMakeLlsts.txt file and any of the other CMake generated files.. Again, many thanks for your help in fixing this.

OUTPUT tab in VScode

[main] Building folder: 9_vcpkg_raylib 
[main] Configuring folder: 9_vcpkg_raylib 
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=/bin/c99-gcc -H/home/vagrant/Desktop/vscode_cpp_projects/9_vcpkg_raylib -B/home/vagrant/Desktop/vscode_cpp_projects/9_vcpkg_raylib/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
[cmake]   Could NOT find raylib (missing: raylib_LIBRARY)
[cmake] Call Stack (most recent call first):
[cmake]   /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
[cmake]   /home/vagrant/Desktop/vcpkg/installed/x64-linux/share/raylib/raylib-config.cmake:47 (find_package_handle_standard_args)
[cmake]   /home/vagrant/Desktop/vcpkg/installed/x64-linux/share/raylib/vcpkg-cmake-wrapper.cmake:3 (_find_package)
[cmake]   /home/vagrant/Desktop/vcpkg/scripts/buildsystems/vcpkg.cmake:211 (include)
[cmake]   CMakeLists.txt:9 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/home/vagrant/Desktop/vscode_cpp_projects/9_vcpkg_raylib/build/CMakeFiles/CMakeOutput.log".

CMakeLists.txt line #9 = find_package(raylib CONFIG REQUIRED)

@pkeir
Copy link

pkeir commented Jan 31, 2021

I had the same initial issue which brought me here. I then cloned from NancyLi1013 via git clone https://github.com/NancyLi1013/vcpkg.git -b dev/NancyLi/fix-raylib, but on Ubuntu I find my simple hello raylib window program then fails with linker errors starting with:

/usr/bin/ld: $HOME/apps/vcpkg/installed/x64-linux/lib/libraylib.a(vulkan.c.o): in function `_glfwInitVulkan':
vulkan.c:(.text+0x25f): undefined reference to `dlopen'

@NancyLi1013
Copy link
Contributor

Thanks for your test and feedback @zipzit and @pkeir.

I will look into this later.

@NancyLi1013
Copy link
Contributor

Hi @heretique and @pkeir

You might not get the correct changes from my branch. The usage should be like this:

   find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAYLIB_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${RAYLIB_LIBRARIES})

@NancyLi1013
Copy link
Contributor

You can do the following steps:

@zipzit
Copy link
Author

zipzit commented Feb 1, 2021

First delete the vcpkg directory, create the clone branch to dev/NancyLi/fix-raylib

$ chmod +x bootstrap-vcpkg.bat
$ ./bootstrap-vcpkg.bat
./bootstrap-vcpkg.bat: line 1: @echo: command not found
./bootstrap-vcpkg.bat: line 2: powershell.exe: command not found

then:

$ chmod +x bootstrap-vcpkg.sh
$ ./bootstrap-vcpkg.sh

lots of downloads, extracts, builds

$ ./vcpkg install raylib

Total elapsed time: 3.661 min

The package raylib:x64-linux provides CMake targets:
    find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAYLIB_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${RAYLIB_LIBRARIES})
$ ./vcpkg integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/vagrant/Desktop/vcpkg/scripts/buildsystems/vcpkg.cmake"

CMake: Configure works well. (definitely different then last time...) CMake: Build, Definite fail. I've attached a file of the build response. First error line

[build] /usr/bin/ld: /home/vagrant/Desktop/vcpkg/installed/x64-linux/lib/libraylib.a(vulkan.c.o): in function `_glfwInitVulkan':
[build] vulkan.c:(.text+0x1df): undefined reference to `dlopen'

zipzit raylib cmake build fail 6AM 1Feb2021.txt

Nancy, thx for your efforts here. Definitely some progress made, not sure about the dlsym stuff

Hmm.. as I think about this one, I'm not sure I tried a manual install of the raylib library. Its not clear if the errors noted are from the vcpkg manager or from raylib stuff itself. Give me a while to figure this out..

@NancyLi1013
Copy link
Contributor

@zipzit

Could you please help provide your application? I try to use raylib on my machine, it can be built successfully on Windows and Linux.

@zipzit
Copy link
Author

zipzit commented Feb 2, 2021

@zipzit -- Could you please help provide your application? I try to use raylib on my machine, it can be built successfully on Windows and Linux.

Sure, Here's my open source repo. As you can tell I'm trying to learn the right progression for using C/C++ on VS Code. Baby steps. Think CodeSandBox Simplicity for learning how-to build and run in C++ #1 thru #6 work fine. #7/#8 not so sure. I jumped over to #9, and that's where I'm working now. I'm working in a Ubuntu environment within Virtualbox. And I do realize, I have to stop and really learn the details on CMake. I'm a hacker there. I'm planning on spending a day playing with that so I understand whats going on. All the working files are just tossed on the desktop. If it helps I can throw the vagrant file here too, (although that's a bit messy..)

https://github.com/zipzit/vscode_cpp_projects

Many thanks for your efforts here...

@zipzit
Copy link
Author

zipzit commented Feb 3, 2021

So I've spent a whole bunch of time on this stuff. When I installed raylib libraries from repo, things worked well. I wasn't happy with their instructions on Include/Link, but with a little bit of research I was able to figure this out. One thing the raylib install does is place the library and include files in best practice location automatically. In my case, /usr/local/include and /usr/local/lib . The build installation tells you that in a comment statement at the end of the build. It did not modify the $PATH variable, and I don't see those directories listed there. I tested three different raylib samples and all work fine with the raylib virgin install, see repo.

Here is my manual raylib install CMakeLists.txt file:

cmake_minimum_required(VERSION 3.0.0)
project(raylib_test3 VERSION 0.1.0)   ## Name the project here!

include(CTest)
enable_testing()

INCLUDE_DIRECTORIES(/usr/local/include)              
LINK_DIRECTORIES(/usr/local/lib)

add_executable(${PROJECT_NAME} main3.cpp)

target_link_libraries(${PROJECT_NAME} raylib)

Not nearly having such a fun time over at VCPKG install. I gotta say, these words drive me insane:

$ ./vcpkg install raylib
...
Package raylib:x64-linux is already installed
...

The package raylib:x64-linux provides CMake targets:

    find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAYLIB_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${RAYLIB_LIBRARIES})

followed by:

$ ./vcpkg integrate install
Applied user-wide integration for this vcpkg root.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/vagrant/Desktop/vcpkg/scripts/buildsystems/vcpkg.cmake"

When those four lines are added to my CMakeLists.txt file, things fail. The fail in different direction, but absolutely everything fails. Note, the -DCMAKE_TOOLCHAIN is converted to set(CMAKE_TOOLCHAIN_FILE /home/vagrant/Desktop/vcpkg/scripts/buildsystems/vcpkg.cmake) And there seems to be some odd cache somewhere tied to that toolchain. I notice when I rename the project, it tries to build the old project name. And I'm working in a build folder within my local repo, deleting the build folder when making changes to CMakeLists.txt.

I gotta say, I came here to VCPKG to do a quick test on a library. And for other support libraries, it works perfectly (e.g. ZeroMQ stuff) For raylib, not so much, sigh. My expectation is that whatever the vcpkg install tells me, that's what I add to the CMakeLists.txt file and it performs. I will say... In the VCPKG overview it does require Visual Studio and instead I'm using VS Code, and it's possible therein lies a difference. But this hasn't been fun.

If anyone wants to duplicate the test, I'll include my vagrant file so you can build the environment on your own in virtualbox. Note, there are some flaky things in the vagrant file depending on windows or Macos (shared folder stuff and Camera setup) But you can remark out the camera / shared folder stuff it should work just fine.

Here's a vagrant file if anyone wants to test the unix stuff easily...

One more note: When I do a $ sudo find / -iname raylib.h on the box, I see that file once at /usr/local/include/ where the raylib install told me it was going, once in the downloaded raylib repo (no surprise there), but I see that file five times within the VCPKG folder. What's up with that? Single source of truth and all? What am I missing?

/home/vagrant/Desktop/vcpkg/packages/raylib_x64-linux/include/raylib.h
/home/vagrant/Desktop/vcpkg/installed/x64-linux/include/raylib.h
/home/vagrant/Desktop/vcpkg/buildtrees/raylib/src/620dc1f990-d2b1ba8177.clean/src/raylib.h
/home/vagrant/Desktop/vcpkg/buildtrees/raylib/x64-linux-rel/src/raylib.h
/home/vagrant/Desktop/vcpkg/buildtrees/raylib/x64-linux-dbg/src/raylib.h

Don't get me wrong, I'm more then grateful for the support from the whole team here. The attempt is noble. But doggone there are a whole lot of open issues here within this repo. I would love to dig in and help, but Its just not clear to me on the concept of what the perfect vcpkg folder looks like. I'm totally lost understanding what the vcpkg.cmake script is trying to accomplish. None of this makes sense to me. At this point, raylib via VCPKG on a unix box is a fail.

@NancyLi1013
Copy link
Contributor

Hi @zipzit

Thanks for looking into this and also for your time.

In fact, vpkg has provided the usage for raylib:

    find_package(raylib CONFIG REQUIRED)
    target_include_directories(main PRIVATE ${RAYLIB_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${RAYLIB_LIBRARIES})

So you just need to use it like this in your project , why do you set the path manually?

INCLUDE_DIRECTORIES(/usr/local/include)              
LINK_DIRECTORIES(/usr/local/lib)

On Linux, vcpkg find headers and libs in path
/home/vagrant/Desktop/vcpkg/installed/x64-linux/include
/home/vagrant/Desktop/vcpkg/installed/x64-linux/lib

So I don't understand what your situation.

@zipzit
Copy link
Author

zipzit commented Feb 5, 2021

Apologies for your confusion on this. That stuff was posted in direct response to my comment above:

Hmm.. as I think about this one, I'm not sure I tried a manual install of the raylib library. Its not clear if the errors noted are from the vcpkg manager or from raylib stuff itself. Give me a while to figure this out..

When I manually install the raylib library from github source, it works great.
When I install the library from VCPKG, including the lines you mentioned, its a total fail. Each of the FOUR lines received from the vcpkg system generate errors. Here, to make it easy for you, click here. You can see BOTH CMakeLists.txt files used. The one labeled CMakeLists.txt.vcpkg is the one I use with vcpkg. The one labeled CMakeLists.txt.raylib is the one I use with the manually installed raylib built from raylib github repo. The manually installed stuff works great (i.e. my .cpp files, each of them work fine.) Obviously I remove the temp suffix when I build.

The VCPKG stuff fails raylib each and every time, no matter what I do.

You know, I provided my vagrant file so you can easily and quickly build the unix box on your computer and test it. When you run the vcpkg stuff for raylib on a unix box are you successful? Many thanks for your patience and efforts here.

@NancyLi1013
Copy link
Contributor

Thanks for your further investigation about this issue.

I cannot reproduce it since there is no project case before this.

And now, I have the same error as you posted above. Seems less to link dl and pthread on Linux. Just add these to link library lists can solve the problem. Will fix it ASAP.
I'm really appreciate your patience and efforts.

@NancyLi1013 NancyLi1013 reopened this Feb 5, 2021
@NancyLi1013
Copy link
Contributor

NancyLi1013 commented Feb 5, 2021

The same error in #16047.

Since the original issue for the usage has been fixed. Let's track the link issue there.

@pkeir
Copy link

pkeir commented Jan 12, 2023

Like @zipzit I also found that Raylib is now lowercase in raylib_INCLUDE_DIRS and raylib_LIBRARIES. Tested on Windows 10, with raylib 4.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants