www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Building Example Project with `raylib-d`

reply jwatson-CO-edu <real.name colorado.edu> writes:
Hello,
I used the following steps to build the example `raylib-d` 
program. (https://github.com/schveiguy/raylib-d#example)


1. `sudo apt install libasound2-dev mesa-common-dev libx11-dev 
libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev`
1. `cd /tmp`
1. `git clone https://github.com/raysan5/raylib.git raylib`
1. `cd raylib`
1. `mkdir build && cd build`
1. `cmake -DBUILD_SHARED_LIBS=ON ..`
1. `make -j2`
1. `sudo make install`
1. `sudo reboot now`


1. Install Dlang
1. Navigate to project root directory
1. `mkdir source`
1. `touch source/app.d`
1. Code: https://github.com/schveiguy/raylib-d#example
1. `dub add raylib-d`
1. `dub build`


```
Performing "debug" build using /usr/bin/dmd for x86_64.
00_test ~master: building configuration "application"...
Linking...
/usr/bin/ld: 
.dub/build/application-debug-linux.posix-x86_64-dmd_v2.100.0-533EF886932B3BC59F9F09D
3C0642F5/00_test.o: in function
`_D6raylib7binding21validateRaylibBindingFNbNiZv':
/home/james/.dub/packages/raylib-d-4.2.0/raylib-d/source/raylib/binding.d:26:
undefined reference to `raylibVersion'
/usr/bin/ld: 
/home/james/.dub/packages/raylib-d-4.2.0/raylib-d/source/raylib/binding.d:26:
undefined reference to `raylibVersion'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
/usr/bin/dmd failed with exit code 1.
```


There appears to be a linker problem with regards to missing 
symbols, but normally I would expect `make install` to place the 
shared libs in their proper places.
1. Have I missed an install step?
1. What are my next troubleshooting steps?
Sep 14 2022
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 9/14/22 4:17 PM, jwatson-CO-edu wrote:
 Hello,
 I used the following steps to build the example `raylib-d` program. 
 (https://github.com/schveiguy/raylib-d#example)
 

 1. `sudo apt install libasound2-dev mesa-common-dev libx11-dev 
 libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev`
 1. `cd /tmp`
 1. `git clone https://github.com/raysan5/raylib.git raylib`
 1. `cd raylib`
 1. `mkdir build && cd build`
 1. `cmake -DBUILD_SHARED_LIBS=ON ..`
 1. `make -j2`
 1. `sudo make install`
 1. `sudo reboot now`
 

 1. Install Dlang
 1. Navigate to project root directory
 1. `mkdir source`
 1. `touch source/app.d`
 1. Code: https://github.com/schveiguy/raylib-d#example
 1. `dub add raylib-d`
 1. `dub build`
 

 ```
 Performing "debug" build using /usr/bin/dmd for x86_64.
 00_test ~master: building configuration "application"...
 Linking...
 /usr/bin/ld: 
 .dub/build/application-debug-linux.posix-x86_64-dmd_v2.100.0-533EF886932B3BC59F9F09D
3C0642F5/00_test.o: 
 in function `_D6raylib7binding21validateRaylibBindingFNbNiZv':
 /home/james/.dub/packages/raylib-d-4.2.0/raylib-d/source/raylib/binding.d:26: 
 undefined reference to `raylibVersion'
 /usr/bin/ld: 
 /home/james/.dub/packages/raylib-d-4.2.0/raylib-d/source/raylib/binding.d:26: 
 undefined reference to `raylibVersion'
 collect2: error: ld returned 1 exit status
 Error: linker exited with status 1
 /usr/bin/dmd failed with exit code 1.
 ```
 

 There appears to be a linker problem with regards to missing symbols, 
 but normally I would expect `make install` to place the shared libs in 
 their proper places.
You built the unreleased version of raylib, where they changed the name of that symbol. (see https://github.com/raysan5/raylib/commit/082920eb800d7d7612d500a4bbc46b21ff232424) Try `git checkout 4.2.0` on the raylib library before building, or use the released binary. raylib is notorious for making breaking changes. On the next release, I will have to update that symbol name. -Steve
Sep 14 2022
parent jwatson-CO-edu <real.name colorado.edu> writes:
On Wednesday, 14 September 2022 at 23:42:57 UTC, Steven 
Schveighoffer wrote:
 On 9/14/22 4:17 PM, jwatson-CO-edu wrote:
 Hello,
 I used the following steps to build the example `raylib-d` 
 program. (https://github.com/schveiguy/raylib-d#example)
 

 1. `sudo apt install libasound2-dev mesa-common-dev libx11-dev 
 libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev 
 libglu1-mesa-dev`
 1. `cd /tmp`
 1. `git clone https://github.com/raysan5/raylib.git raylib`
 1. `cd raylib`
 1. `mkdir build && cd build`
 1. `cmake -DBUILD_SHARED_LIBS=ON ..`
 1. `make -j2`
 1. `sudo make install`
 1. `sudo reboot now`
 

 1. Install Dlang
 1. Navigate to project root directory
 1. `mkdir source`
 1. `touch source/app.d`
 1. Code: https://github.com/schveiguy/raylib-d#example
 1. `dub add raylib-d`
 1. `dub build`
 

 ```
 Performing "debug" build using /usr/bin/dmd for x86_64.
 00_test ~master: building configuration "application"...
 Linking...
 /usr/bin/ld: 
 .dub/build/application-debug-linux.posix-x86_64-dmd_v2.100.0-533EF886932B3BC59F9F09D
3C0642F5/00_test.o: in function
`_D6raylib7binding21validateRaylibBindingFNbNiZv':
 /home/james/.dub/packages/raylib-d-4.2.0/raylib-d/source/raylib/binding.d:26:
undefined reference to `raylibVersion'
 /usr/bin/ld: 
 /home/james/.dub/packages/raylib-d-4.2.0/raylib-d/source/raylib/binding.d:26:
undefined reference to `raylibVersion'
 collect2: error: ld returned 1 exit status
 Error: linker exited with status 1
 /usr/bin/dmd failed with exit code 1.
 ```
 

 There appears to be a linker problem with regards to missing 
 symbols, but normally I would expect `make install` to place 
 the shared libs in their proper places.
You built the unreleased version of raylib, where they changed the name of that symbol. (see https://github.com/raysan5/raylib/commit/082920eb800d7d7612d500a4bbc46b21ff232424) Try `git checkout 4.2.0` on the raylib library before building, or use the released binary. raylib is notorious for making breaking changes. On the next release, I will have to update that symbol name. -Steve
That worked immediately, thank you! Honored to have the direct attention of and detailed advice from the package author. I have the corrected install instructions below, in case someone finds this post while resolving the same issue: 1. `sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev` 1. `cd /tmp` 1. `git clone https://github.com/raysan5/raylib.git raylib` 1. `cd raylib` currently targeted by `raylib-d` 1. `mkdir build && cd build` 1. `cmake -DBUILD_SHARED_LIBS=ON ..` 1. `make -j2` 1. `sudo make install` 1. `sudo reboot now` 1. Install Dlang 1. Navigate to project root directory 1. `mkdir source` 1. `touch source/app.d` 1. Code: https://github.com/schveiguy/raylib-d#example 1. `dub add raylib-d` 1. `dub build` 1. `./PROJECTNAME`
Sep 14 2022