DSFML icon indicating copy to clipboard operation
DSFML copied to clipboard

Network Problem under OSX

Open luke5542 opened this issue 10 years ago • 5 comments

As I was running the unit tests for DSFML to test the Packet changes in #204, I saw a few assertion failures and then the unit test for Packet hung for a minute before I stopped it. I then pulled out the unit testing code into its own program to debug it and got the following error:

Linking...
Undefined symbols for architecture x86_64:
  "_D5dsfml7network11tcplistener11TcpListener6__ctorMFZC5dsfml7network11tcplistener11TcpListener", referenced from:
      __Dmain in dsfml-test.o
  "_D5dsfml7network11tcplistener11TcpListener7__ClassZ", referenced from:
      __Dmain in dsfml-test.o
  "_D5dsfml7network12__ModuleInfoZ", referenced from:
      _D3app12__ModuleInfoZ in dsfml-test.o
  "_D5dsfml7network6packet6Packet6__ctorMFZC5dsfml7network6packet6Packet", referenced from:
      __Dmain in dsfml-test.o
  "_D5dsfml7network6packet6Packet7__ClassZ", referenced from:
      __Dmain in dsfml-test.o
  "_D5dsfml7network6packet6Packet9checkSizeMFmZb", referenced from:
      _D5dsfml7network6packet6Packet11__T4readTkZ4readMFJkZb in dsfml-test.o
      _D5dsfml7network6packet6Packet11__T4readTaZ4readMFJaZb in dsfml-test.o
      _D5dsfml7network6packet6Packet11__T4readTiZ4readMFJiZb in dsfml-test.o
      _D5dsfml7network6packet6Packet11__T4readTdZ4readMFJdZb in dsfml-test.o
      _D5dsfml7network6packet6Packet11__T4readTbZ4readMFJbZb in dsfml-test.o
      _D5dsfml7network6packet6Packet11__T4readTmZ4readMFJmZb in dsfml-test.o
      _D5dsfml7network6packet6Packet11__T4readTfZ4readMFJfZb in dsfml-test.o
      ...
  "_D5dsfml7network6packet7__arrayZ", referenced from:
      _D5dsfml7network6packet6Packet14__T5writeTAyaZ5writeMFNaNbAyaZv in dsfml-test.o
      _D5dsfml7network6packet6Packet13__T4readTAyaZ4readMFJAyaZb in dsfml-test.o
  "_D5dsfml7network9ipaddress9IpAddress9LocalHostyS5dsfml7network9ipaddress9IpAddress", referenced from:
      __Dmain in dsfml-test.o
  "_D5dsfml7network9tcpsocket9TcpSocket6__ctorMFZC5dsfml7network9tcpsocket9TcpSocket", referenced from:
      __Dmain in dsfml-test.o
  "_D5dsfml7network9tcpsocket9TcpSocket7__ClassZ", referenced from:
      __Dmain in dsfml-test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--- errorlevel 1
dmd failed with exit code 1.

I changed back to the current master branch's code and checked the unittests for Packet in the same manner (stick them in a method "stupidTest" and just run) and the error message barely changed (note, for ease of use I just shoved this into a previous project that uses the current master branch rather than actually moving things around):

Linking...
Undefined symbols for architecture x86_64:
  "_D5dsfml7network11tcplistener11TcpListener6__ctorMFZC5dsfml7network11tcplistener11TcpListener", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
  "_D5dsfml7network11tcplistener11TcpListener7__ClassZ", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
  "_D5dsfml7network12__ModuleInfoZ", referenced from:
      _D7ridgway10pmgcrawler3app12__ModuleInfoZ in pmgcrawler.o
  "_D5dsfml7network6packet6Packet6__ctorMFZC5dsfml7network6packet6Packet", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
  "_D5dsfml7network6packet6Packet7__ClassZ", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
  "_D5dsfml7network9ipaddress9IpAddress9LocalHostyS5dsfml7network9ipaddress9IpAddress", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
  "_D5dsfml7network9tcpsocket9TcpSocket6__ctorMFZC5dsfml7network9tcpsocket9TcpSocket", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
  "_D5dsfml7network9tcpsocket9TcpSocket7__ClassZ", referenced from:
      _D7ridgway10pmgcrawler3app10stupidTestFZv in pmgcrawler.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--- errorlevel 1
dmd failed with exit code 1.

I tried with both the precompiled DSFMLC library files on dsfml.com and by compiling them on my own and both gave this error. When running the unittests for DSFML I do not get this error, but my two other attempts to use the networking library from another program resulted in this symbol failure.

luke5542 avatar Dec 24 '15 23:12 luke5542

It looks like you're missing the D library stuff. Any undefined symbols from DSFMLC start with sf (like sfPacket_readInt for example). Are you linking the static libraries or using the files directly?

Jebbs avatar Dec 24 '15 23:12 Jebbs

The DSFML code is being compiled through dub in both cases. I think I'll try building this without dub and just linking the static libraries and see if that helps, but it's weird that this would start only when I add in the network library, rather than just dsfml.graphics.

Update: that made no difference.

luke5542 avatar Dec 25 '15 00:12 luke5542

Yeah, that is strange. Let me know how it goes. But don't work too much today or tomorrow!

Jebbs avatar Dec 25 '15 00:12 Jebbs

Yea, it really is... Thanks, you too!

luke5542 avatar Dec 25 '15 00:12 luke5542

okay, so I had no luck solving the issue using the regular command line setup, but I fixed it on the dub side and now I feel silly. Perhaps this is a lesson to remember and mention in the tutorials?

You were right that I wasn't linking things correctly, but it turns out that the problem was with the dsfml:graphics dependency, as listed in the tutorial. My fix was the oh-so-simple conversion of specifying dsfml instead, which tells it where to find everything, rather than just what's needed by the graphics submodule. It makes perfect sense that this is the problem, I just feel a bit silly having not found it earlier.

I think a quick update to the tutorial would suffice for saving others the trouble, and then this can be closed.

luke5542 avatar Dec 25 '15 03:12 luke5542