Hi,
i want to develop a new app that uses the USBDM interface and i have difficulties when i try to compile the USBDM_API_Example.cpp.
I am using codeblocks and mingw to compile the app but i keep getting undefined reference on the usbdm_api.
||=== Build: Release in usbdmapitest (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp|| undefined reference to `_imp__USBDM_GetErrorString@4'|
obj\Release\main.o:main.cpp|| undefined reference to `_imp__USBDM_Close@0'|
obj\Release\main.o:main.cpp|| undefined reference to `_imp__USBDM_Exit@0'|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
the header file is in the same dir as the the cpp file and i keep getting these errors. Can i have some help? Is that an issue of the DLL file?
Any help is highly appreciated.
Solved! Go to Solution.
pgo thank you for the reply.
The problem that i had was that i couldnt find a way to link the dll file to the project.
So here is what i did and it worked like a charm. (For future reference to anyone looking to do the same).
Go to "Project -> Build Options". Select "Release", "Debug" or both and then go to "Linker Settings" tab and click "Add".
On the window that opens choose "All Files" and then select the dll file that you want to link and click "Open".
Click "Yes" on the next dialog and you are set.
Thank you pgo for showing me the way
Hi Padelis,
I suspect that you are failing to link against the usbdm DLL when building. This will result in the errors you are seeing.
Check how to add the library to the linking step for your build environment. For GCC the usual command option would be -lusbdm.4.
The log from a successful build using minGW gcc is show below. You can check the command lines against those used by your compiler.
16:53:30 **** Incremental Build of configuration Default for project USBDM_API_Example ****
mingw32-make all
c:/Apps/MinGW/bin/mingw32-make exe -f Target.mk BUILDDIR=USBDM_API_Example CDEFS='-DUSE_ICON'
mingw32-make[1]: Entering directory 'C:/Users/podonoghue/Development/USBDM/EclipseUSBDMExamples/USBDM_API_Example'
c:/Apps/MinGW/msys/1.0/bin/mkdir USBDM_API_Example
c:/Apps/MinGW/msys/1.0/bin/touch USBDM_API_Example/timestamp
-- Building USBDM_API_Example/USBDM_API_Example.o from src/USBDM_API_Example.cpp
c:/Apps/MinGW/bin/g++ -mthreads -O3 -g0 -DUSE_ICON -Isrc -MD -c src/USBDM_API_Example.cpp -o USBDM_API_Example/USBDM_API_Example.o
-- Building USBDM_API_Example/Version.o from src/Version.rc
c:/Apps/MinGW/bin/windres src/Version.rc -DUSE_ICON -Isrc -o USBDM_API_Example/Version.o
--
-- Linking Target USBDM_API_Example/USBDM_API_Example.exe
c:/Apps/MinGW/bin/g++ -o USBDM_API_Example/USBDM_API_Example.exe -mthreads -s USBDM_API_Example/USBDM_API_Example.o USBDM_API_Example/Version.o -L. -lusbdm.4
mingw32-make[1]: Leaving directory 'C:/Users/podonoghue/Development/USBDM/EclipseUSBDMExamples/USBDM_API_Example'
c:/Apps/MinGW/bin/mingw32-make exe -f Target.mk BUILDDIR=USBDM_API_Example-debug CDEFS='-DUSE_ICON' DEBUG='Y'
mingw32-make[1]: Entering directory 'C:/Users/podonoghue/Development/USBDM/EclipseUSBDMExamples/USBDM_API_Example'
mingw32-make[1]: Nothing to be done for 'exe'.
mingw32-make[1]: Leaving directory 'C:/Users/podonoghue/Development/USBDM/EclipseUSBDMExamples/USBDM_API_Example'
16:53:32 Build Finished (took 1s.670ms)
bye
I think that i am using the wrong files. It sure has to do with linking the dll as you mention.
Can you give me a layout of the source folders that i should use? I am on WinXP and have installed the latest version of USBDM.
Thank you for your reply
Hi Padelis,
I usually do work using Eclipse with MinGW. The following screen grab shows the required files to build the example application:
This project is included in the USBDM installation and is available in Eclipse if installed.
You can get these files from the directory (path will vary):
C:\Program Files (x86)\pgo\USBDM 4.10.6.120\Examples\USBDM_API_Example.zip
Since you are using Codeblocks you need to add the cpp file to your 'project' and make sure the header files are available (in the same directory?). The dlls will need to be added as well. I have no idea how to do this with Codeblocks.
Alternatively, since you have MinGW installed you can just unzip the above file and then open a command line in the directory and build the example by typing (path will vary):
c:\Apps\MinGW\bin\mingw32-make.exe
bye
pgo thank you for the reply.
The problem that i had was that i couldnt find a way to link the dll file to the project.
So here is what i did and it worked like a charm. (For future reference to anyone looking to do the same).
Go to "Project -> Build Options". Select "Release", "Debug" or both and then go to "Linker Settings" tab and click "Add".
On the window that opens choose "All Files" and then select the dll file that you want to link and click "Open".
Click "Yes" on the next dialog and you are set.
Thank you pgo for showing me the way