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

sdl2-net x64-linux not building #3505

Closed
amaiorano opened this issue May 16, 2018 · 4 comments
Closed

sdl2-net x64-linux not building #3505

amaiorano opened this issue May 16, 2018 · 4 comments

Comments

@amaiorano
Copy link
Contributor

Output from shell:

daroou@daroou-VirtualBox:~/code/vcpkg$ ./vcpkg install sdl2-net
The following packages will be built and installed:
    sdl2-net[core]:x64-linux
Starting package 1/1: sdl2-net:x64-linux
Building package sdl2-net[core]:x64-linux... 
-- CURRENT_INSTALLED_DIR=/home/daroou/code/vcpkg/installed/x64-linux
-- DOWNLOADS=/home/daroou/code/vcpkg/downloads
-- CURRENT_PACKAGES_DIR=/home/daroou/code/vcpkg/packages/sdl2-net_x64-linux
-- CURRENT_BUILDTREES_DIR=/home/daroou/code/vcpkg/buildtrees/sdl2-net
-- CURRENT_PORT_DIR=/home/daroou/code/vcpkg/ports/sdl2-net
-- Using cached /home/daroou/code/vcpkg/downloads/SDL2_net-2.0.1.tar.gz
-- Testing integrity of cached file...
-- Testing integrity of cached file... OK
-- Extracting done
-- Configuring x64-linux-dbg
-- Configuring x64-linux-dbg done
-- Configuring x64-linux-rel
-- Configuring x64-linux-rel done
-- Build x64-linux-dbg
CMake Error at scripts/cmake/vcpkg_build_cmake.cmake:170 (message):
    Command failed: /home/daroou/code/vcpkg/downloads/tools/cmake-3.10.2-linux/cmake-3.10.2-Linux-x86_64/bin/cmake;--build;.;--config;Debug;--target;install;--;-v;-j1
    Working Directory: /home/daroou/code/vcpkg/buildtrees/sdl2-net/x64-linux-dbg
    See logs for more information:
      /home/daroou/code/vcpkg/buildtrees/sdl2-net/install-x64-linux-dbg-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
  ports/sdl2-net/portfile.cmake:18 (vcpkg_install_cmake)
  scripts/ports.cmake:72 (include)


Error: Building package sdl2-net:x64-linux failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: sdl2-net:x64-linux
  Vcpkg version: 0.0.111-unknownhash

Additionally, attach any relevant sections from the log files above.

Contents of /home/daroou/code/vcpkg/buildtrees/sdl2-net/install-x64-linux-dbg-out.log:

[1/6] /usr/bin/cc -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/home/daroou/code/vcpkg/installed/x64-linux/include/SDL2 /wd4244 /wd4996 -g -MD -MT CMakeFiles/SDL2_net.dir/SDLnet.c.o -MF CMakeFiles/SDL2_net.dir/SDLnet.c.o.d -o CMakeFiles/SDL2_net.dir/SDLnet.c.o   -c /home/daroou/code/vcpkg/buildtrees/sdl2-net/src/SDL2_net-2.0.1/SDLnet.c
FAILED: CMakeFiles/SDL2_net.dir/SDLnet.c.o
/usr/bin/cc -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/home/daroou/code/vcpkg/installed/x64-linux/include/SDL2 /wd4244 /wd4996 -g -MD -MT CMakeFiles/SDL2_net.dir/SDLnet.c.o -MF CMakeFiles/SDL2_net.dir/SDLnet.c.o.d -o CMakeFiles/SDL2_net.dir/SDLnet.c.o   -c /home/daroou/code/vcpkg/buildtrees/sdl2-net/src/SDL2_net-2.0.1/SDLnet.c
cc: error: /wd4244: No such file or directory
cc: error: /wd4996: No such file or directory
[2/6] /usr/bin/cc -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/home/daroou/code/vcpkg/installed/x64-linux/include/SDL2 /wd4244 /wd4996 -g -MD -MT CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o -MF CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o.d -o CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o   -c /home/daroou/code/vcpkg/buildtrees/sdl2-net/src/SDL2_net-2.0.1/SDLnetTCP.c
FAILED: CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o
/usr/bin/cc -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/home/daroou/code/vcpkg/installed/x64-linux/include/SDL2 /wd4244 /wd4996 -g -MD -MT CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o -MF CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o.d -o CMakeFiles/SDL2_net.dir/SDLnetTCP.c.o   -c /home/daroou/code/vcpkg/buildtrees/sdl2-net/src/SDL2_net-2.0.1/SDLnetTCP.c
cc: error: /wd4244: No such file or directory
cc: error: /wd4996: No such file or directory
[3/6] /usr/bin/cc -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/home/daroou/code/vcpkg/installed/x64-linux/include/SDL2 /wd4244 /wd4996 -g -MD -MT CMakeFiles/SDL2_net.dir/SDLnetselect.c.o -MF CMakeFiles/SDL2_net.dir/SDLnetselect.c.o.d -o CMakeFiles/SDL2_net.dir/SDLnetselect.c.o   -c /home/daroou/code/vcpkg/buildtrees/sdl2-net/src/SDL2_net-2.0.1/SDLnetselect.c
FAILED: CMakeFiles/SDL2_net.dir/SDLnetselect.c.o
/usr/bin/cc -D_WINSOCK_DEPRECATED_NO_WARNINGS -I/home/daroou/code/vcpkg/installed/x64-linux/include/SDL2 /wd4244 /wd4996 -g -MD -MT CMakeFiles/SDL2_net.dir/SDLnetselect.c.o -MF CMakeFiles/SDL2_net.dir/SDLnetselect.c.o.d -o CMakeFiles/SDL2_net.dir/SDLnetselect.c.o   -c /home/daroou/code/vcpkg/buildtrees/sdl2-net/src/SDL2_net-2.0.1/SDLnetselect.c
cc: error: /wd4244: No such file or directory
cc: error: /wd4996: No such file or directory
ninja: build stopped: subcommand failed.
@amaiorano
Copy link
Contributor Author

amaiorano commented May 23, 2018

I have a fix for this issue on this PR: #3564

The problem is that in vcpkg/ports/sdl2-net/CMakeLists.txt, there are Windows specific compile flags being passed, namely:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4996")

Wrapping this up in an if (MSVC) fixes the problem for me:

if (MSVC)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4996")
endif()

This allows for sdl-net to build properly on Ubuntu. However, when I attempt to link against sdl-net and sdl, both built with vcpkg, I have linker errors that require that I link against sndio and dl. Is this expected, or should the vcpkg cmake file specify public dependencies like these?

@ras0219-msft
Copy link
Contributor

Thanks for the PR! Watching your archived stream 76 ATM :)

Some answers to questions you had during the stream:

  1. Yes, vcpkg should add the public dependencies to the SDL2 targets so you don't have to explicitly link them! (We don't do this currently, but it is something we should strive to do in the future)
  2. When using static libraries, as you discovered, you do need to specify all the "transitive" dependencies on the link line. You are depending on these either way (shared or static), but when using shared libs that's "hidden" from you until runtime.
  3. sndio is a lower level library used by SDL2 to access sound on Linux. We probably should build this statically in vcpkg.
  4. libdl is a very, very low level library on linux supplying dlclose(), dlsym(), etc (as you found out). This one will pretty much always come from your system, like the CRT. We should definitely be injecting the -ldl automatically though!
  5. The change you made to SDL2-net was great :) In the future we should probably also guard the target_link_libraries(... ws2_32), however this statement is actually ignored[1] when building static libraries, since no link actually happens!
  6. It should actually be pretty rare that ports have their own CMakeLists.txt. This only happens when we need to replace the host buildsystem (which happens when it is more difficult to maintain compatibility with their existing buildsystem than to maintain our own copy). Ports like SDL2 are using upstream's CMakeLists.txt
  7. Sorry for the long delay without response this issue! While working on Linux & OSX support, a pretty large backlog built up and we prioritize PRs over issues, so we're currently playing catch-up :)

[1] If you export cmake targets (not sure if you're familiar with that) the the target_link_libraries() will be added to those targets and pulled into the consuming project (even for static libs). We don't do that currently, so it has no effect.

@amaiorano
Copy link
Contributor Author

Wow @ras0219-msft! Thanks so much for the detailed response -- and for actually watching my stream (how did you even figure out the link between my issue here and that specific stream?).

As you can probably tell, my experience is mainly as a Windows dev, with some minor dabbling in the Linux world, so it's really great to have someone as helpful as you answer these questions of mine.

I'm so glad that I'm now able to build my emulator on Linux using vcpkg in the same way I do on Windows! I tested running it on a clean Ubuntu install, and the only dependency that needed to be installed was sndio, so what you said about building it statically in vcpkg would be awesome. Does this mean you'd need someone to contribute sndio as a package for vcpkg?

#6 explains what I was wondering about - why some of the ports had CMakeLists.txt while others did not; thank you for that.

#7 - this was not a long delay at all :) Thank you very much for taking the time. I love vcpkg, and am so glad we finally have a tool like this on Windows -- and even better, on Linux and Mac as well!

Cheers!

@LarryIII
Copy link
Contributor

LarryIII commented Feb 2, 2019

PR #3564 was merged. So closed this issue!

@LarryIII LarryIII closed this as completed Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants