linker problem using wxDev-C++

C, C++, and Visual C++
phoenix2307

linker problem using wxDev-C++

Postby phoenix2307 » Mon Apr 20, 2009 1:56 pm

Hello,
I just bought a 1064 MotorControl HC board.
I have installed the provided library and all is working perfectly.
Then i tryed to compile the example, using wxDev-Cpp (MinGW compiler).

I removed deprecated functions calls warnings...,
added phidget21.lib library file in the compiler options.

Then, when trying a built:
> Compilation seem successful.
! But, linker operation fail with this prompt:

Compilateur: Default GCC compiler
Building Makefile: "D:\PROJECT robot\Phidgets\exemples\Dev-CPP\MotorCtrl\Makefile.win"
Exécution de make...
mingw32-make.exe -f "D:\PROJECT robot\Phidgets\exemples\Dev-CPP\MotorCtrl\Makefile.win" all
g++.exe Objects/MingW/main.o -o "Output\MingW\simple-motor_ctrl.exe" -L"C:/Program Files/Dev-Cpp/Lib" -L"D:/PROJECT robot/Phidgets/exemples/Dev-CPP/MotorCtrl" -L"D:/PROJECT robot/Phidgets/exemples/Dev-CPP/MotorCtrl" phidget21.lib -g3

Objects/MingW/main.o:main.cpp:(.text+0x114): undefined reference to `_imp__CPhidget_getDeviceName@8'
Objects/MingW/main.o:main.cpp:(.text+0x12b): undefined reference to `_imp__CPhidget_getSerialNumber@8'
Objects/MingW/main.o:main.cpp:(.text+0x16c): undefined reference to `_imp__CPhidget_getDeviceName@8'
Objects/MingW/main.o:main.cpp:(.text+0x183): undefined reference to `_imp__CPhidget_getSerialNumber@8'
Objects/MingW/main.o:main.cpp:(.text+0x26c): undefined reference to `_imp__CPhidget_getDeviceType@8'
Objects/MingW/main.o:main.cpp:(.text+0x283): undefined reference to `_imp__CPhidget_getSerialNumber@8'
Objects/MingW/main.o:main.cpp:(.text+0x29a): undefined reference to `_imp__CPhidget_getDeviceVersion@8'
Objects/MingW/main.o:main.cpp:(.text+0x2b1): undefined reference to `_imp__CPhidgetMotorControl_getInputCount@8'
Objects/MingW/main.o:main.cpp:(.text+0x2c8): undefined reference to `_imp__CPhidgetMotorControl_getMotorCount@8'

Objects/MingW/main.o:main.cpp:(.text+0x334): undefined reference to `_imp__CPhidgetMotorControl_create@4'
Objects/MingW/main.o:main.cpp:(.text+0x354): undefined reference to `_imp__CPhidget_set_OnAttach_Handler@12'
Objects/MingW/main.o:main.cpp:(.text+0x374): undefined reference to `_imp__CPhidget_set_OnDetach_Handler@12'
Objects/MingW/main.o:main.cpp:(.text+0x394): undefined reference to `_imp__CPhidget_set_OnError_Handler@12'
Objects/MingW/main.o:main.cpp:(.text+0x3b4): undefined reference to `_imp__CPhidgetMotorControl_set_OnInputChange_Handler@12'
Objects/MingW/main.o:main.cpp:(.text+0x3d4): undefined reference to `_imp__CPhidgetMotorControl_set_OnVelocityChange_Handler@12'
Objects/MingW/main.o:main.cpp:(.text+0x3f4): undefined reference to `_imp__CPhidgetMotorControl_set_OnCurrentChange_Handler@12'
Objects/MingW/main.o:main.cpp:(.text+0x40c): undefined reference to `_imp__CPhidget_open@8'
Objects/MingW/main.o:main.cpp:(.text+0x430): undefined reference to `_imp__CPhidget_waitForAttachment@8'
Objects/MingW/main.o:main.cpp:(.text+0x450): undefined reference to `_imp__CPhidget_getErrorDescription@8'
Objects/MingW/main.o:main.cpp:(.text+0x4b9): undefined reference to `_imp__CPhidgetMotorControl_setAcceleration@16'
Objects/MingW/main.o:main.cpp:(.text+0x4db): undefined reference to `_imp__CPhidgetMotorControl_setVelocity@16'
Objects/MingW/main.o:main.cpp:(.text+0x50e): undefined reference to `_imp__CPhidgetMotorControl_setAcceleration@16'
Objects/MingW/main.o:main.cpp:(.text+0x530): undefined reference to `_imp__CPhidgetMotorControl_setVelocity@16'
Objects/MingW/main.o:main.cpp:(.text+0x55f): undefined reference to `_imp__CPhidgetMotorControl_setVelocity@16'
Objects/MingW/main.o:main.cpp:(.text+0x57d): undefined reference to `_imp__CPhidgetMotorControl_setAcceleration@16'
Objects/MingW/main.o:main.cpp:(.text+0x5aa): undefined reference to `_imp__CPhidget_close@4'
Objects/MingW/main.o:main.cpp:(.text+0x5ba): undefined reference to `_imp__CPhidget_delete@4'
collect2: ld returned 1 exit status

mingw32-make.exe: *** [Output/MingW/simple-motor_ctrl.exe] Error 1

Exécution terminée



According to other topics founded on the forum, i am not the only one having problems at this level.
I am not closed to others compilers, just want to understand why it isn't working with this one (i have not yet tried other one)
But if Borland requires an other library to work with (phidget21bcc.lib), maybe MinGW needs too a specific one?

I put here the Makefile created:

# Project: Projet1
# Compiler: Default GCC compiler
# Compiler Type: MingW 3
# Makefile created by wxDev-C++ 6.10.2 on 20/04/09 20:54

CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = Objects/MingW/main.o
LINKOBJ = Objects/MingW/main.o
LIBS = -L"C:/Program Files/Dev-Cpp/Lib" -L"D:/PROJECT robot/Phidgets/exemples/Dev-CPP/MotorCtrl" -L"D:/PROJECT robot/Phidgets/exemples/Dev-CPP/MotorCtrl" phidget21.lib -g3
INCS = -I"include" -I"D:/PROJECT robot/Phidgets/exemples/Dev-CPP/MotorCtrl"
CXXINCS = -I"C:/Program Files/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Program Files/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Program Files/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Program Files/Dev-Cpp/include/c++/3.4.2" -I"C:/Program Files/Dev-Cpp/include" -I"C:/Program Files/Dev-Cpp/" -I"C:/Program Files/Dev-Cpp/include/common/wx/msw" -I"C:/Program Files/Dev-Cpp/include/common/wx/generic" -I"C:/Program Files/Dev-Cpp/include/common/wx/fl" -I"C:/Program Files/Dev-Cpp/include/common/wx/gizmos" -I"C:/Program Files/Dev-Cpp/include/common/wx/html" -I"C:/Program Files/Dev-Cpp/include/common/wx/mmedia" -I"C:/Program Files/Dev-Cpp/include/common/wx/net" -I"C:/Program Files/Dev-Cpp/include/common/wx/ogl" -I"C:/Program Files/Dev-Cpp/include/common/wx/plot" -I"C:/Program Files/Dev-Cpp/include/common/wx/protocol" -I"C:/Program Files/Dev-Cpp/include/common/wx/stc" -I"C:/Program Files/Dev-Cpp/include/common/wx/svg" -I"C:/Program Files/Dev-Cpp/include/common/wx/xml" -I"C:/Program Files/Dev-Cpp/include/common/wx/xrc" -I"C:/Program Files/Dev-Cpp/include/common/wx" -I"C:/Program Files/Dev-Cpp/include/common" -I"D:/PROJECT robot/Phidgets/exemples/Dev-CPP/MotorCtrl"
RCINCS = --include-dir "C:/PROGRA~1/Dev-Cpp/include/common" -I"D:/PROJEC~1/Phidgets/exemples/Dev-CPP/MOTORC~1"
BIN = Output/MingW/simple-motor_ctrl.exe
DEFINES =
CXXFLAGS = $(CXXINCS) $(DEFINES) -g3
CFLAGS = $(INCS) $(DEFINES) -g3
GPROF = gprof.exe
RM = rm -f
LINK = g++.exe

.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after

clean: clean-custom
$(RM) $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(LINK) $(LINKOBJ) -o "Output\MingW\simple-motor_ctrl.exe" $(LIBS)

Objects/MingW/main.o: $(GLOBALDEPS) main.cpp phidget21.h
$(CPP) -c main.cpp -o Objects/MingW/main.o $(CXXFLAGS)


Thanks for your help.

Don
Site Admin
Posts: 3
Joined: Tue Mar 10, 2009 3:50 pm
Contact:

Re: linker problem using wxDev-C++

Postby Don » Wed Apr 22, 2009 12:26 pm

Hi,

Here at Phidgets we've written the guide and tested the library against the MinGW compiler from http://www.mingw.org/ and have difficulty reproducing this problem. If you could try the next troubleshooting steps, I will update the guide to reflect any findings.

From the error log you posted, it appears your compiler is unable to find or unable to parse the phidget21.lib file. Try placing one of the x86 and x64 versions of the phidget21.lib file in the project directory and then include it in your project settings. Using the wrong version will give the undefined reference error. If this does not work, please try downloading the latest MinGW compiler from http://www.mingw.org/ and try to compile the example manually from the console to see if it is a compiler issue.

It also seems to be a common theme that people try to compile the Linux Phidget Libraries and headers on Windows as a workaround. I would like to stress that this is not going to work, and to use the lib and header files directly from the latest VC/VC++/Borland Platform files (http://www.phidgets.com/downloads.php?example_id=17). Editing the header file is as simple as doing a find and replace of “__declspec (deprecated” with “//__declspec (deprecated”.

Thank you very much,


Don

phoenix2307

Re: linker problem using wxDev-C++

Postby phoenix2307 » Tue Apr 28, 2009 3:33 pm

Hi Don,

I tryed the next troobleshooting steps.
Here is the operations performed:

- Download and installation of the last MinGW compiler version (3.4.5) from http://www.mingw.org/

Here are the gz packages inside (custom settings):

binutils-2.17.50-20060824-1.tar.gz
gcc-core-3.4.5-20060117-3.tar.gz
gcc-g++-3.4.5-20060117-3.tar.gz
gcc-objc-3.4.5-20060117-3.tar.gz
mingw32-make-3.81-20080326-2.tar.gz
mingwrt-3.15.1-mingw32.tar.gz
w32api-3.12-mingw32-dev.tar.gz

All of them have been uncompressed, contents are now stored in C:\MinGW

- To simplify the manual compilation of the project, the exemple of MotorCtrl is now located in C:\MotorCtrl
(instead of previously: D:\PROJECT robot\Phidgets\exemples\Dev-CPP\MotorCtrl) :lol:

- I removed the old main.o file in C:\MotorCtrl\Objects\MingW

- Now, from the command line prompt:

Code: Select all

C:\MinGW\bin>g++.exe -c "C:\MotorCtrl\main.cpp" -o "C:\MotorCtrl\Objects\MingW\main.o" -I"C:\MinGW\include" -I"C:\MinGW\include\c++\3.4.5\backward" -I"C:\MinGW\include\c++\3.4.5\mingw32" -I"C:\MinGW\include\c++\3.4.5" -I"C:\MinGW\include" -I"C:\MotorCtrl"

Compilation passed with success. A new main.o file has been created (7ko) in C:\MotorCtrl\Objects\MingW.
Now linking with:

Code: Select all

C:\MinGW\bin>g++.exe "C:\MotorCtrl\Objects\MingW\main.o" -o "C:\MotorCtrl\Output\MingW\simple-motor_ctrl.exe" -L "C:\MotorCtrl\phidget21-x86_2.1.6.20090417.lib"



But unfortunately, liking pass failed again with...

C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x112): undefined reference to
`_imp__CPhidget_getDeviceName@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x129): undefined reference to
`_imp__CPhidget_getSerialNumber@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x16a): undefined reference to
`_imp__CPhidget_getDeviceName@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x181): undefined reference to
`_imp__CPhidget_getSerialNumber@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x26a): undefined reference to
`_imp__CPhidget_getDeviceType@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x281): undefined reference to
`_imp__CPhidget_getSerialNumber@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x298): undefined reference to
`_imp__CPhidget_getDeviceVersion@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x2af): undefined reference to
`_imp__CPhidgetMotorControl_getInputCount@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x2c6): undefined reference to
`_imp__CPhidgetMotorControl_getMotorCount@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x332): undefined reference to
`_imp__CPhidgetMotorControl_create@4'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x352): undefined reference to
`_imp__CPhidget_set_OnAttach_Handler@12'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x372): undefined reference to
`_imp__CPhidget_set_OnDetach_Handler@12'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x392): undefined reference to
`_imp__CPhidget_set_OnError_Handler@12'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x3b2): undefined reference to
`_imp__CPhidgetMotorControl_set_OnInputChange_Handler@12'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x3d2): undefined reference to
`_imp__CPhidgetMotorControl_set_OnVelocityChange_Handler@12'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x3f2): undefined reference to
`_imp__CPhidgetMotorControl_set_OnCurrentChange_Handler@12'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x40a): undefined reference to
`_imp__CPhidget_open@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x42e): undefined reference to
`_imp__CPhidget_waitForAttachment@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x44e): undefined reference to
`_imp__CPhidget_getErrorDescription@8'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x4b7): undefined reference to
`_imp__CPhidgetMotorControl_setAcceleration@16'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x4d9): undefined reference to
`_imp__CPhidgetMotorControl_setVelocity@16'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x50c): undefined reference to
`_imp__CPhidgetMotorControl_setAcceleration@16'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x52e): undefined reference to
`_imp__CPhidgetMotorControl_setVelocity@16'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x55d): undefined reference to
`_imp__CPhidgetMotorControl_setVelocity@16'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x57b): undefined reference to
`_imp__CPhidgetMotorControl_setAcceleration@16'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x5a8): undefined reference to
`_imp__CPhidget_close@4'
C:\MotorCtrl\Objects\MingW\main.o:main.cpp:(.text+0x5b8): undefined reference to
`_imp__CPhidget_delete@4'
collect2: ld returned 1 exit status


I retryed the same operation with the x64 library, but same errors occured...
(I didn't mentioned it before, my OS is Win XP with SP2.)


Cordially.

Don
Site Admin
Posts: 3
Joined: Tue Mar 10, 2009 3:50 pm
Contact:

Re: linker problem using wxDev-C++

Postby Don » Wed Apr 29, 2009 3:32 pm

Ah, posting the detailed steps is quite helpful. In the command prompt, does it compile if you omit the -L when building with the library?

g++.exe "C:\MotorCtrl\Objects\MingW\main.o" "C:\MotorCtrl\phidget21-x86_2.1.6.20090417.lib"

MooseHole

Re: linker problem using wxDev-C++

Postby MooseHole » Thu Apr 30, 2009 10:20 am

I was able to link by upgrading gcc to version 4.3.0 (MinGW's alpha release). Version 3.4.5 doesn't seem to work. See my thread for more details: viewtopic.php?f=2&t=2813

phoenix2307

Re: linker problem using wxDev-C++

Postby phoenix2307 » Tue May 19, 2009 1:57 pm

thanks both for your help!
Finaly, it works...

Don, you were right, without the -L argument, it works much better :P
(I still using the 3.4.5 version for now, but i will certainly have a try later with newer version)

Code: Select all

g++.exe "C:\MotorCtrl\Objects\MingW\main.o" "C:\MotorCtrl\phidget21-x86_2.1.6.20090417.lib"


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 4 guests