[zeromq-dev] Problems building zmq
Arnaud Loonstra
arnaud at sphaero.org
Wed Nov 20 17:54:40 CET 2019
If I issue
pkg-config --libs libczmq
I get
-L/usr/local/lib -lczmq
So I guess you should do
gcc zmqserver.c -o zmqserver -lczmq -L.
instead of libcmzq. This is on Debian but I guess Ubuntu is the same.
Rg,
Arnaud
On 20-11-2019 17:23, Bill Engelke wrote:
> Hello all:
>
> I would like to work with zmq in C, and I have hit problems trying to
> compile and link the server/client example here
> <https://zeromq.org/get-started/?language=c> and trying to build any of
> the zguide examples here
> <https://github.com/booksbyus/zguide/tree/master/examples/C>.
>
> Platform: Ubuntu (tried all of this using first the ARM libraries on an
> Odroid, then the x86_64 libraries on a PC running Ubuntu); same results
>
> I used sudo-apt-get install libczmq-dev (this is the only package I
> can find available for Ubuntu)
>
> sudo ldconfig
>
> I have verified that the shared library is present in
> /usr/lib/x86_64-linux-gnu/ (libczmq, that is libczmq.so)
>
> When I use this:
>
> gcc zmqserver.c -o zmqserver -llibczmq -L.
>
> I get:
>
> /usr/bin/ld: cannot find -llibczmq
>
> collect2: error: ld returned 1 exit status
>
> I have tried referencing the library directly:
>
> /usr/bin/ld: cannot find -l:/usr/lib/x86_64-linux-gnu/libczmq
>
> collect2: error: ld returned 1 exit status
>
> I have tried every possible combination of the order of the link
> references I can come up with, all with the same result.
>
> Running using the verbose flag, we get:
>
> gcc zmqserver.c -o zmqserver -llibczmq -L. -v
>
> Using built-in specs.
>
> COLLECT_GCC=gcc
>
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
>
> OFFLOAD_TARGET_NAMES=nvptx-none
>
> OFFLOAD_TARGET_DEFAULT=1
>
> Target: x86_64-linux-gnu
>
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu
> 7.4.0-1ubuntu1~18.04.1'
> --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
> --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
> --prefix=/usr --with-gcc-major-version-only --program-suffix=-7
> --program-prefix=x86_64-linux-gnu- --enable-shared
> --enable-linker-build-id --libexecdir=/usr/lib
> --without-included-gettext --enable-threads=posix --libdir=/usr/lib
> --enable-nls --with-sysroot=/ --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes
> --with-default-libstdcxx-abi=new --enable-gnu-unique-object
> --disable-vtable-verify --enable-libmpx --enable-plugin
> --enable-default-pie --with-system-zlib --with-target-system-zlib
> --enable-objc-gc=auto --enable-multiarch --disable-werror
> --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
> --enable-multilib --with-tune=generic
> --enable-offload-targets=nvptx-none --without-cuda-driver
> --enable-checking=release --build=x86_64-linux-gnu
> --host=x86_64-linux-gnu --target=x86_64-linux-gnu
>
> Thread model: posix
>
> gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
>
> COLLECT_GCC_OPTIONS='-o' 'zmqserver' '-L.' '-v' '-mtune=generic'
> '-march=x86-64'
>
> /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -quiet -v -imultiarch
> x86_64-linux-gnu zmqserver.c -quiet -dumpbase zmqserver.c -mtune=generic
> -march=x86-64 -auxbase zmqserver -version -fstack-protector-strong
> -Wformat -Wformat-security -o /tmp/cc2R1v53.s
>
> GNU C11 (Ubuntu 7.4.0-1ubuntu1~18.04.1) version 7.4.0 (x86_64-linux-gnu)
>
> compiled by GNU C version 7.4.0, GMP version 6.1.2,
> MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
>
> GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
>
> ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
>
> ignoring nonexistent directory
> "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
>
> #include "..." search starts here:
>
> #include <...> search starts here:
>
> /usr/lib/gcc/x86_64-linux-gnu/7/include
>
> /usr/local/include
>
> /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
>
> /usr/include/x86_64-linux-gnu
>
> /usr/include
>
> End of search list.
>
> GNU C11 (Ubuntu 7.4.0-1ubuntu1~18.04.1) version 7.4.0 (x86_64-linux-gnu)
>
> compiled by GNU C version 7.4.0, GMP version 6.1.2,
> MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
>
> GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
>
> Compiler executable checksum: fa57db1fe2d756b22d454aa8428fd3bd
>
> COLLECT_GCC_OPTIONS='-o' 'zmqserver' '-L.' '-v' '-mtune=generic'
> '-march=x86-64'
>
> as -v --64 -o /tmp/ccKlQGoW.o /tmp/cc2R1v53.s
>
> GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU
> Binutils for Ubuntu) 2.30
>
> COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
>
> LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
>
> COLLECT_GCC_OPTIONS='-o' 'zmqserver' '-L.' '-v' '-mtune=generic'
> '-march=x86-64'
>
> /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin
> /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so
> -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
> -plugin-opt=-fresolution=/tmp/ccOSG0IO.res
> -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
> -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
> -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr
> -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker
> /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o zmqserver
> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o
> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o
> /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L.
> -L/usr/lib/gcc/x86_64-linux-gnu/7
> -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu
> -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib
> -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu
> -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../..
> /tmp/ccKlQGoW.o -llibczmq -lgcc --push-state --as-needed -lgcc_s
> --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state
> /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o
> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
>
> /usr/bin/ld: cannot find -llibczmq
>
> collect2: error: ld returned 1 exit status
>
> Trying to build the zguide examples shows that something is missing or
> misconfigured for that as well: (using library cloned from
> https://github.com/booksbyus/zguide)
>
> ./build hwserver
>
> hwserver
>
> /usr/bin/ld: cannot find -luuid
>
> collect2: error: ld returned 1 exit status
>
> I have looked thru online discussion groups to the point of exhaustion;
> some possible ideas here
> <https://stackoverflow.com/questions/19406024/c-linker-cannot-find-lcrypto-but-the-library-is-in-the-path>
> and here
> <https://stackoverflow.com/questions/335928/ld-cannot-find-an-existing-library>,
> but still no luck.
>
> What am I missing? -B.E.
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
More information about the zeromq-dev
mailing list