Compiling GLEW with Cygwin, undefined references (mostly to glXGetProcAddressARB) - cygwin

I am trying to compile GLEW in cygwin. I downloaded glew version 1.11.0 from the website and extracted it into C:\glew-1.11.0\. Then after navigating into the folder in cygwin (run as admin) and doing make, it errors with the following. Doing make all does the same (if this matters).
/cygdrive/c/glew-1.11.0
$ cc -shared -Wl,--out-implib,lib/libGLEW.dll.a -o lib/cygGLEW--.dll tmp/cygwin/default/shared/glew.o -lopengl32 -lX11
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x34b): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x364): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x37d): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x396): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x3af): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x3c8): more undefined references to `glXGetProcAddressARB' follow
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x141c1): undefined reference to `glGetString'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x14220): undefined reference to `glXGetClientString'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x1426e): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x142b8): undefined reference to `glXQueryVersion'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x142e2): undefined reference to `glXGetClientString'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x14387): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x14939): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x14952): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x14988): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x149a1): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x149ba): more undefined references to `glXGetProcAddressARB' follow
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x164af): undefined reference to `glGetString'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x1674e): undefined reference to `glGetString'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x16795): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x167ae): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x167c7): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x167e0): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x16891): undefined reference to `glXGetProcAddressARB'
tmp/cygwin/default/shared/glew.o:glew.c:(.text+0x168aa): more undefined references to `glXGetProcAddressARB' follow
collect2: error: ld returned 1 exit status
Any idea how to get glew to compile?

GLEW packages are available in Cygwin Ports; you can see how they are built here.

Adding #define _WIN32 to all the .c files in glew-1.11.0\src\ seemed to get it to compile, though there were a lot of things like:
warning ‘__glewVertexAttrib3fNV’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV = NULL;

Related

ares link errors building Tensorflow from source with bazel on Ubuntu 18.04

bazel build -c opt -- //tensorflow/...
produces these errors (after running for a long while):
ERROR: /home/luke/tensorflow/tensorflow/c/eager/BUILD:125:1: Linking of rule '//tensorflow/c/eager:c_api_test_gpu' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc -o bazel-out/k8-opt/bin/tensorflow/c/eager/c_api_test_gpu '-Wl,-rpath,$ORIGIN/../../../_solib_k8/' -Lbazel-out/k8-opt/bin/_solib_k8 ... (remaining 64 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_library_cleanup'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_library_init'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_inet_ntop'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_parse_srv_reply'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_free_data'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_parse_txt_reply_ext'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_query'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_search'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_gethostbyname'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_set_servers_ports'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_strerror'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_init'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_process_fd'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_cancel'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_getsock'
bazel-out/k8-opt/bin/_solib_k8/libexternal_Sgrpc_Slibgrpc_Uresolver_Udns_Uares.so: error: undefined reference to 'ares_destroy'
I tried running sudo apt-get install libc-ares-dev, which did address some of the build steps depending on c-ares, but not this one
I built c-ares from source and ran make install which places the .so libcares.so in /usr/local/lib/. I also verified that libcares does export those symbols. That didn't solve anything.
I made sure my LD_LIBRARY_PATH included /usr/local/lib/
How to I get bazel to find the library?
Thank you in advance.

After I compile mrpt manually, I have a trouble with build mrpt files

I'm trying to combine every system with ros but before that I wanted to check whether it works well or not so I run file on CLion, and I got these errors.
/home/ian/Downloads/clion-2017.2.1/bin/cmake/bin/cmake --build /home/ian/CLionProjects/mrqt --target mrpt -- -j 4
[ 50%] Linking CXX executable mrpt
/usr/bin/ld: warning: libopencv_imgcodecs3.so.3.2, needed by /usr/local/lib/libmrpt-base.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_imgproc3.so.3.2, needed by /usr/local/lib/libmrpt-base.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libopencv_core3.so.3.2, needed by /usr/local/lib/libmrpt-base.so, not found (try using -rpath or -rpath-link)
/usr/local/lib/libmrpt-base.so: undefined reference to `cvLoadImage'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvConvertImage'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvReleaseImage'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvSplit'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvMatchTemplate'
/usr/local/lib/libmrpt-base.so: undefined reference to `_IplImage::_IplImage(cv::Mat const&)'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvCreateImage'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvSmooth'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvFlip'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvGetSize'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvCvtColor'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvCircle'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvGetQuadrangleSubPix'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvRemap'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvLine'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvSaveImage'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvCopy'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvCloneImage'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvSetImageROI'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvEqualizeHist'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvMinMaxLoc'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvMerge'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvResize'
/usr/local/lib/libmrpt-base.so: undefined reference to `cvUndistort2'
collect2: error: ld returned 1 exit status
CMakeFiles/mrpt.dir/build.make:94: recipe for target 'mrpt' failed
make[3]: *** [mrpt] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mrpt.dir/all' failed
make[2]: *** [CMakeFiles/mrpt.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/mrpt.dir/rule' failed
make[1]: *** [CMakeFiles/mrpt.dir/rule] Error 2
Makefile:118: recipe for target 'mrpt' failed
make: *** [mrpt] Error 2
When I first compiled it, it was fine, but later I had some issues with mrpt header files, I deleted them all and compiled it manually, and this problem happened. Can I get some advice?
You probably have a mix of different MRPT versions installed in your system.
I don't recommend doing sudo make install unless you have a strong reason to do it; just compiling the project in its own build directory will generate a MRPTConfig.cmake file, which allows CMake to find MRPT from ROS or whatever other user project.
If CMake doesn't find it automatically, just set the environment variable export MRPT_DIR=/home/xxx/path/to/mrpt/build and it will work.
Your problem right now is cleaning all the mess that may be under /usr/local/. Take a look at that directory and if the only project you have make installed is MRPT, I strongly recommend deleting it with sudo rm -fr /usr/local/*.
If you have other projects there... well... you must run sudo make uninstall from the MRPT build dir, then manually make sure there are no remaining files.
The link error against OpenCV also looks like CMake configured the project for one opencv version, then another one got installed (perhaps via ROS packages?).
After doing the clean up of /usr/local mentioned above, delete your current MRPT CMake build directory and start from scratch again.

OpenPose Library - build release issue

We are trying to install and run a demo for OpenPose Library available on Github :
https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md#manual-compilation
Done with installing Caffe and all prerequisites, but while performing install command we are getting following errror :
CXX examples/tutorial_wrapper/2_user_synchronous.cpp
AR -o .build_release/lib/libopenpose.a
LD -o .build_release/lib/libopenpose.so.1.0.0-rc3
CXX/LD -o .build_release/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.bin
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::VideoCapture(cv::String const&)'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::set(int, double)'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::release()'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::isOpened() const'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::get(int) const'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::VideoCapture(int)'
.build_release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::~VideoCapture()'
.build_release/lib/libopenpose.so: undefined reference to `vtable for cv::VideoWriter'
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.bin' failed
make: *** [.build_release/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.bin] Error 1
make: *** Waiting for unfinished jobs....
------------------------- -------------------------
Errors detected. Exiting script. The software might have not been successfully installed.
------------------------- -------------------------
Please help me get rid of this.
Thanks
This could be because libopencv_video and/or libopencv_videoio has not been added to the project. If you build opencv from source, do check whether these libraries have been built.
It looks like you did not check the OpenCV3 flag in both the OpenPose and Caffe makefiles.config files.
E.g., if you are using manual compilation as you indicated, assume you have Ubuntu 16 and CUDA 8. So you need to modify both these files:
https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/Makefile.config.Ubuntu16.example
https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/3rdparty/caffe/Makefile.config.Ubuntu16.example
By uncommenting # OPENCV_VERSION := 3 in both of them.
After that simply run again the command they specify: cp Makefile.config.Ubuntu16.example Makefile.config
And make clean in both OpenPose and Caffe and re-build it again.

Undefine reference for libraries, so How could I find the right path?

I am trying to compile a v4l2 example in Ubuntu but I am getting the following error:
guilherme#notedev01:~/Downloads/V4l2_samples-0.4.1$ make
gcc -O2 -L/usr/include -lX11 -lXext -o viewer viewer.c
/tmp/ccUjnjWQ.o: In function `image_destroy':
viewer.c:(.text+0x234): undefined reference to `XDestroyImage'
viewer.c:(.text+0x256): undefined reference to `XFreeGC'
viewer.c:(.text+0x277): undefined reference to `XShmDetach'
viewer.c:(.text+0x2ac): undefined reference to `XFreePixmap'
/tmp/ccUjnjWQ.o: In function `image_create':
viewer.c:(.text+0x305): undefined reference to `XCreateGC'
viewer.c:(.text+0x31d): undefined reference to `XGetWindowAttributes'
viewer.c:(.text+0x39e): undefined reference to `XShmCreateImage'
viewer.c:(.text+0x3f5): undefined reference to `XShmAttach'
viewer.c:(.text+0x44e): undefined reference to `XCreateImage'
viewer.c:(.text+0x494): undefined reference to `XShmQueryExtension'
viewer.c:(.text+0x4b4): undefined reference to `XShmPixmapFormat'
viewer.c:(.text+0x4dc): undefined reference to `XShmCreatePixmap'
/tmp/ccUjnjWQ.o: In function `image_put':
viewer.c:(.text+0x54c): undefined reference to `XPutImage'
viewer.c:(.text+0x586): undefined reference to `XShmPutImage'
/tmp/ccUjnjWQ.o: In function `main':
viewer.c:(.text.startup+0x18b): undefined reference to `XOpenDisplay'
viewer.c:(.text.startup+0x1b1): undefined reference to `XScreenOfDisplay'
viewer.c:(.text.startup+0x1ee): undefined reference to `XCreateSimpleWindow'
viewer.c:(.text.startup+0x249): undefined reference to `XMapRaised'
viewer.c:(.text.startup+0x263): undefined reference to `XStoreName'
viewer.c:(.text.startup+0x280): undefined reference to `XGetWindowAttributes'
viewer.c:(.text.startup+0x92f): undefined reference to `XPending'
viewer.c:(.text.startup+0x94c): undefined reference to `XNextEvent'
viewer.c:(.text.startup+0xaee): undefined reference to `XPending'
viewer.c:(.text.startup+0xb0b): undefined reference to `XNextEvent'
viewer.c:(.text.startup+0xf39): undefined reference to `XPending'
viewer.c:(.text.startup+0xf56): undefined reference to `XNextEvent'
collect2: error: ld returned 1 exit status
make: *** [viewer] Error 1
What I can see is that the path for -lx11 and -lXext isn't -L/usr/include.
How can I find the right path for those libraries?
Thanks.
as Chris has pointed out, the order is wrong, you need to put the -lX11 -lXext after the source-code/object-files.
this is because modern compilers try to optimize the final result and not link against unused libraries.
they do so by maintaining a list of unresolved symbols within an object and use any binary files that come aferwards in the linker arguments to resolve those symbols.
example
your program test uses the function do_foo() from libfoo and the function do_bar_do() from libbar.
you link it using:
$ gcc -o test test.o -lfoo -lbar
the linker first searches test.o and notices that some symbols (do_foo and do_bar_do) are not defined anywhere. it then proceeds to libfoo (specified right after test.o) and finds that it provides do_foo, so it creates code to use it from your program. do_bar_do is still unresolved, until the linker checks upon libbar.
consider doing it the wrong way:
$ gcc -o test -lfoo test.o -lbar
the linker will first check libfoo and see that it doesn't contain any unresolved symbols. cool. it will then proceed to test.o and notice do_bar_do and do_foo. do_bar_do is resolved by the right-hand libbar but do_foo is not resolved at all, and you get an error:
undefined reference to `do_foo'
"but the code is meant to be a tutorial..."
so why is it not working?
older compilers where a bit lax about the order of dependencies (they would check all binaries/libraries/objects whether a given symbol could be resolved); that's why you can still find code out there that puts the libraries to link against before the object files.
The -lX11 -lXext must come after the viewer.c in the command line (and should probably be in the order -lXext -lX11). Also, ensure that the libx11-6-dev and libxext6-dev packages are installed.
System libraries are usually in /lib and /usr/lib, and you do not need to use -L to specify those directories.

Undefined Reference at Linking in Static Git Build

I'm trying to install git on a shared server (with no root access or compiler) by building it statically on my own machine (running Arch Linux) with the same processor architecture (x86_64) as the server, as explained in this guide.
When I ran make, I always got these errors and a failure:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x19): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x2c): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x37): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x364): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x422): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x494): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x552): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x5c2): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x62d): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x65a): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x6ef): undefined reference to `dladdr'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x749): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
(.text+0x7aa): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [git-imap-send] Error 1
I finally discovered a different guide, which advised running a slightly different .configure command. What ended up working for me was this guide, with the exception of running
$ ./configure --prefix=/home/myuser/git-static CFLAGS="${CFLAGS} -static" NO_OPENSSL=1 NO_CURL=1
in step 2.
The error message indicates it can't find the definition of
dlclose
dlerror
dleopen
You need to make sure your makefile has -ldl when link the application.
LDFLAGS are for the linker flags. LIBS are for the linked libraries. Confusing them is not usually a problem, but in the case of static libs or when the linker has the --as-needed option enabled the order of libraries matters and any -l passed before libs that use it will be ignored.

Resources