dermesser / libsocket

The ultimate socket library for C and C++, supporting TCP, UDP and Unix sockets (DGRAM and STREAM) on Linux, FreeBSD, Solaris. See also my uvco library for a refreshed version!
https://borgac.net/~lbo/doc/libsocket/
Other
797 stars 195 forks source link

compile error #48

Open wzhsunn opened 7 years ago

wzhsunn commented 7 years ago
=== MAKE SURE YOU INSTALLED THE LATEST VERSION AS S/O! ===
Starting test suite examples/...
Testing HTTP client...
/tmp/ccFFSk2Z.o: In function `main':
http.c:(.text+0x37): undefined reference to `create_inet_stream_socket'
http.c:(.text+0x116): undefined reference to `shutdown_inet_stream_socket'
http.c:(.text+0x190): undefined reference to `destroy_inet_socket'
collect2: error: ld returned 1 exit status

os info:


 uname -a
Linux iZ25wcw25xrZ 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
dermesser commented 7 years ago

Have you installed the library on your system? (make install)

whitecloudy commented 5 years ago

@dermesser I have the same issue and I installed the library on my system.

dermesser commented 5 years ago

Are you sure that the library is in a place that the linker can find it, i.e. in your LDPATH?

whitecloudy commented 5 years ago

@dermesser I did "ldconfig" command as well. C library is working fine when I write in c language and compile with gcc. But when I tried to use C++ library or C library with c++ language while compiling with g++, it doesn't work.

whitecloudy commented 5 years ago

Just to make sure, I also tried both of -lsocket++ and -lsocket as well.

dermesser commented 5 years ago

I can't reproduce the issue; on my system it links and runs well. Do you have more information?

whitecloudy commented 5 years ago

I cannot understand...... after a few days, the compiling suddenly work properly......

By the way, how can I use C library in C++?

whitecloudy commented 5 years ago

compile_log.txt


This is what I am struggling right now.

dermesser commented 5 years ago

so is it working or is it not?

for the C library from C++, you can try this:

extern "C" {
#include <libsocket/libinetsocket.h>
}

and then use the symbols normally.

whitecloudy commented 5 years ago

I made a very very huge mistake..... I made put my -lsocket in front of the source code names in Makefile. This is why Makefile doesn't work.

whitecloudy commented 5 years ago

This is quite embarrassing but I'll leave it for other people.

dermesser commented 5 years ago

ah well, I didn't see it either :)