I am trying to set up a cmake build environment on Windows for EAL lib application development.
I’ve been using the manual in the docs for creating an EAL project for Windows on Eclipse as a loose guide for implementing this, and I’ve run into a library linking issue. The linker throws undefined reference errors for any EAL lib function calls.
Here are the libraries that I am linking:
Here is the include directory that I am using:
The compiler is MinGW64 and the file I am trying to compile is DownloadFirmware.c from the code samples.
Any thoughts on what I might be doing wrong?
Solved! Go to Solution.
your include and link directories are correct.
For your reference I've created a small cmake skript to build the DownloadFirmware sample.
cmake_minimum_required(VERSION 3.10) project(DownloadFirmware VERSION 1.0) #set include directories to default EAL install path include_directories("C:/Program Files (x86)/Rexroth/EAL-SDK/02VRS/eal4c/include") #set link directories to default EAL install path link_directories("C:/Program Files (x86)/Rexroth/EAL-SDK/02VRS/eal4c/bin/mono/win32") link_directories("C:/Program Files (x86)/Rexroth/EAL-SDK/02VRS/eal4c/bin") add_executable(DownloadFirmware DownloadFirmware.c) target_link_libraries(DownloadFirmware libEALCWrapper-win32.dll) target_link_libraries(DownloadFirmware mono-2.0-sgen.dll)
To run your program you need to copy libEALCWrapper-win32.dll and mono-2.0-sgen.dll to same folder where your executatble is located.
I tried using the provided cmake file and putting the dlls in the build directory. The program now compiles without linking errors but at runtime the program throws missing library errors and exits. See GDB output here:
PS C:\Users\cpawlowicz\dev\bosch_workbench\build> cmake --build .
[ 50%] Building C object CMakeFiles/DownloadFirmware.dir/DownloadFirmware.c.obj
[100%] Linking C executable DownloadFirmware.exe
[100%] Built target DownloadFirmware
PS C:\Users\cpawlowicz\dev\bosch_workbench\build> gdb .\DownloadFirmware.exe
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from .\DownloadFirmware.exe...done.
Starting program: C:\Users\cpawlowicz\dev\bosch_workbench\build\DownloadFirmware.exe
[New Thread 25352.0x7a4]
[New Thread 25352.0x66b4]
[New Thread 25352.0xaa0]
[New Thread 25352.0x2424]
[Thread 25352.0x66b4 exited with code 3221225781]
[Thread 25352.0x2424 exited with code 3221225781]
During startup program exited with code 0xc0000135.
I was able to reproduce this error when I delete one of the mentioned dlls from the folder of my exeecutable or when using a 32bit library when a 64bit lib was linked.
So please double check if you use and copy the correct libraries.
When using a 32bit MinGW use these libs:
C:\Program Files (x86)\Rexroth\EAL-SDK\02VRS\eal4c\bin\libEALCWrapper-win32.dll
C:\Program Files (x86)\Rexroth\EAL-SDK\02VRS\eal4c\bin\mono\win32\mono-2.0-sgen.dll
When using a 64bit MinGW use these libs:
C:\Program Files (x86)\Rexroth\EAL-SDK\02VRS\eal4c\bin\libEALCWrapper-win64.dll
C:\Program Files (x86)\Rexroth\EAL-SDK\02VRS\eal4c\bin\mono\win64\mono-2.0-sgen.dll
When changing between 2 architectures be sure to copy the correct libs (32 or 64bit) to the folder of your executable.
According this post it could also be an issue with your MinGW setup - so you should check the path variable: