Compiling Unicorn Linux C API on Raspberry PI 4 - c++

I am trying to compile this github repository on a Raspberry Pi 4 running Ubuntu 18.04. The code is written on c++.
https://github.com/unicorn-bi/Unicorn-Suite-Hybrid-Black/tree/master/Unicorn%20Raspberry%20Pi%20Zero%20W%20C%20API/UnicornCAPIAcquisitionExample
When I run the following line as in the example:
g++ main.cpp -I ../Lib -L ../Lib -lunicorn -o UnicornAcquisitionExample
I get the following error:
/usr/bin/ld: skipping incompatible ../Lib/libunicorn.so when searching for -lunicorn
/usr/bin/ld: cannot find -lunicorn
collect2: error: ld returned 1 exit status
It seems the shared library file is not compatible. This is weird since it should run also on the Raspberry Pi 4. I have tried to replicate the shared library file and I have tried to compile it also without it. I get always the following error:
/tmp/ccrr59RO.o: In function 'main':
main.cpp:(.text+0xb8): undefined reference to 'UNICORN_GetAvailableDevices'
main.cpp:(.text+0x140): undefined reference to 'UNICORN_GetAvailableDevices'
main.cpp:(.text+0x300): undefined reference to 'UNICORN_OpenDevice'
main.cpp:(.text+0x3e8): undefined reference to 'UNICORN_GetNumberOfAcquiredChannels'
main.cpp:(.text+0x3f4): undefined reference to 'UNICORN_GetConfiguration'
main.cpp:(.text+0x53c): undefined reference to 'UNICORN_StartAcquisition'
main.cpp:(.text+0x5e0): undefined reference to 'UNICORN_GetData'
main.cpp:(.text+0x654): undefined reference to 'UNICORN_StopAcquisition'
main.cpp:(.text+0x6fc): undefined reference to 'UNICORN_CloseDevice'
collect2: error: ld returned 1 exit status
I am not sure if I should try to replicate the shared library file or doing without it but in either case I get always the following error. How can I compile the example in the github on the Raspberry Pi 4?

Related

undefined reference to FOLDERID_.. - C++

compiling c++ from linux to windows using g++ and got an error.
Error:
undefined reference to `FOLDERID_RoamingTiles'
collect2: error: ld returned 1 exit status
I'm guessing there is a library I have to reference but I don't know what the name is.
also if that's the case what are the ways I could find the name of the library I have to reference, if that happens again in the future?
thanks.
I'm compiling under msys2/gcc. linking to uuid helped me.
g++ -luuid -o ....

Undefined reference to nlopt_... symbols

I am fairly new to Fortran and this may sound like a silly question. I encounter an error when compiling the Fortran code that is posted as an example in the NLOPT Wiki.
I compile in Ubuntu 18.04 LTS using the following command:
gfortran example-nlopt.f90 -o example-nlopt -I/usr/local/include/
The following error is produced in the terminal:
/tmp/ccbAim6b.o: In function `MAIN__':
example-nlopt.f90:(.text+0x26): undefined reference to `nlo_create_'
example-nlopt.f90:(.text+0x42): undefined reference to `nlo_get_lower_bounds_'
example-nlopt.f90:(.text+0x67): undefined reference to `nlo_set_lower_bounds_'
example-nlopt.f90:(.text+0x8a): undefined reference to `nlo_set_min_objective_'
example-nlopt.f90:(.text+0xca): undefined reference to `nlo_add_inequality_constraint_'
example-nlopt.f90:(.text+0x10e): undefined reference to `nlo_add_inequality_constraint_'
example-nlopt.f90:(.text+0x12d): undefined reference to `nlo_set_xtol_rel_'
example-nlopt.f90:(.text+0x164): undefined reference to `nlo_optimize_'
example-nlopt.f90:(.text+0x305): undefined reference to `nlo_destroy_'
collect2: error: ld returned 1 exit status
Based on what I saw in nlopt's documentation (https://nlopt.readthedocs.io/en/latest/NLopt_Installation/#changing-the-installation-directory) it looks like you just need to specify the library to link against. Maybe try this:
gfortran -I/usr/local/include/ -L/usr/local/lib example-nlopt.f90 -o example-nlopt -lnlopt -lm
This assumes you have the libnlopt.so in /usr/local/lib, if not then point to its location with the -L option.

Undefined reference to Magick::Image ::Image() in eclipse c++

I am using Eclipse CDT on windows 7 64 bit and trying to work on Image Class using Image Magick but I am getting the below error-
#pragma warning(once: 4459) /* 'identifier' : declaration of 'foo' hides global declaration */
g++ "-LC:\\Development\\ImageMagick-7.0.3-Q16\\lib" "- LC:\\Development\\opencv\\MINGW\\x86\\bin" -o testOpencv.exe "src\\testOpencv.o" -llibopencv_features2d2410 -lCORE_RL_Magick++_ -lCORE_RL_MagickCore_ - lCORE_RL_MagickWand_ -llibopencv_objdetect2410 -llibopencv_contrib2410 - llibopencv_core2410 -llibopencv_flann2410 -llibopencv_gpu2410 - llibopencv_highgui2410 -llibopencv_imgproc2410 -llibopencv_ml2410 - llibopencv_legacy2410 -llibopencv_nonfree2410 -llibopencv_objdetect2410 - llibopencv_ocl2410 -llibopencv_photo2410 -llibopencv_stitching2410 - llibopencv_superres2410 -llibopencv_video2410 -llibopencv_videostab2410 - lopencv_ffmpeg2410 -llibopencv_ml2410
src\testOpencv.o: In function `main':
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:14: undefined reference to `Magick::Image::Image()'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:15: undefined reference to `Magick::Image::read(std::string const&)'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:16: undefined reference to `Magick::Image::display()'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:16: undefined reference to `Magick::Image::~Image()'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:16: undefined reference to `Magick::Image::~Image()'
collect2.exe: error: ld returned 1 exit status
14:28:39 Build Finished (took 847ms)
I have added includes file to compiler and Library files in the linker in Eclipse. The library file in Image magick installed folder look strange to me, as they are not '.dll' files. Please let me know if I am right and how do i rectify this.

__imp link errors using g++ running under mingw

I have a simple socket program that I'm trying to compile using g++ running in mingw (both the latest versions) on a Win8 system. I'm getting the common linker errors
undefined reference to `__imp_socket'
undefined reference to `__imp_gethostbyname'
I've tried adding -lws2_32 with no luck; i.e. it still can't find the references. Can someone suggest something else I might be missing?
Here's the full output:
G:\source\kak>g++ -o ./test_client -lws2_32 test_client.C
C:\Users\kenkahn\AppData\Local\Temp\ccDZTr9b.o:test_client.C:(.text+0x4f): undefined reference to `__imp_inet_addr'
C:\Users\kenkahn\AppData\Local\Temp\ccDZTr9b.o:test_client.C:(.text+0x6b): undefined reference to `__imp_socket'
C:\Users\kenkahn\AppData\Local\Temp\ccDZTr9b.o:test_client.C:(.text+0x8b): undefined reference to `__imp_connect'
d:/program files/mingw/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\kenkahn\AppData\Local\Temp\ccDZTr9b.o: bad reloc address 0xc in section `.xdata'
collect2.exe: error: ld returned 1 exit status
Try putting the -lws2_32 after the test_client.C parameter. The linker of gcc (ld) is touchy about the order of linkable things, this is probably why it doesn't find your imported functions at link time.

trouble linking to libglut.a in D

I have a simple openGL D program that compiles, but I can't get it to link with libglut.a. I've tried a few different command lines:
$ dmd life.d -lglut
$ dmd life.d -L-lglut
$ dmd life.d -L/usr/lib/libglut.a
$ dmd life.d /usr/lib/libglut.a
All of these print the following errors:
life.o:(.data+0x10): undefined reference to `_D1c2gl4glut12__ModuleInfoZ'
life.o:(.data+0x14): undefined reference to `_D1c2gl2gl12__ModuleInfoZ'
life.o: In function `_Dmain':
life.d:(.text._Dmain+0x72): undefined reference to `_D1c2gl4glut8glutInitT1c2gl4glut10pfglutInit'
life.d:(.text._Dmain+0x87): undefined reference to `_D1c2gl4glut19glutInitDisplayModeT1c2gl4glut21pfglutInitDisplayMode'
life.d:(.text._Dmain+0xa1): undefined reference to `_D1c2gl4glut18glutInitWindowSizeT1c2gl4glut20pfglutInitWindowSize'
life.d:(.text._Dmain+0xc2): undefined reference to `_D1c2gl4glut16glutCreateWindowT1c2gl4glut18pfglutCreateWindow'
life.d:(.text._Dmain+0xd7): undefined reference to `_D1c2gl4glut15glutDisplayFuncT1c2gl4glut17pfglutDisplayFunc'
life.d:(.text._Dmain+0xe6): undefined reference to `_D1c2gl4glut12glutMainLoopT1c2gl4glut14pfglutMainLoop'
collect2: ld returned 1 exit status
--- errorlevel 1
Is there a problem with my command lines, or is it something else?
Those look like mangled symbols from D code. You mentioned on your previous question that you were using some kind of compatibility layer – did you make sure to include the files or libraries from that in your build?