g++ linker trouble with tkcmdsetCSAFE_init_protocol

Post questions and issues with Concept2 PM3 SDK
Post Reply
TheRocketeer
500m Poster
Posts: 99
Joined: January 23rd, 2013, 10:44 pm

g++ linker trouble with tkcmdsetCSAFE_init_protocol

Post by TheRocketeer » July 9th, 2013, 8:25 am

Folks,

I am trying to compile a very basic C++ app using the C2 SDK and GCC on Cygwin, but am running into some odd linking problems. Basically I wrote a "main" function based on the documentation on p. 44 of the SDK API manual. Here's what I get:

Code: Select all

$ make
g++.exe -static \
        -LC2 \
        -lws2_32 -lstdc++ -lPM3CsafeCP -lPM3DDICP -lPM3USBCP \
        C2/*.lib \
        C2/*.dll \
        c2example.cc \
        -o c2manipulate.exe
c2example.cc: In function ‘UINT16_T discoverDevices()’:
c2example.cc:95:50: warning: deprecated conversion from string constant to ‘INT8_T* {aka char*}’ [-Wwrite-strings]
c2example.cc:104:100: warning: deprecated conversion from string constant to ‘INT8_T* {aka char*}’ [-Wwrite-strings]
c2example.cc:113:100: warning: deprecated conversion from string constant to ‘INT8_T* {aka char*}’ [-Wwrite-strings]
c2example.cc: At global scope:
c2example.cc:132:5: warning: second argument of ‘int main(int, char***)’ should be ‘char **’ [-Wmain]
c2example.cc: In function ‘int main(int, char***)’:
c2example.cc:175:3: warning: deprecated conversion from string constant to ‘INT8_T* {aka char*}’ [-Wwrite-strings]
c2example.cc:182:3: warning: deprecated conversion from string constant to ‘INT8_T* {aka char*}’ [-Wwrite-strings]
/tmp/ccPVAbDZ.o:c2example.cc:(.text+0x222): undefined reference to `tkcmdsetCSAFE_init_protocol'
collect2: error: ld returned 1 exit status
Makefile:3: recipe for target `all' failed
make: *** [all] Error 1
$
When I have run MSVC's "dumpbin" on the relevant DLLs, all the symbols for tkcmdsetCSAFE_init_protocol appear, so it looks like the linker just isn't finding the reference properly.

Any thoughts?
"You can't outrun a donut." -- TomR

TheRocketeer
500m Poster
Posts: 99
Joined: January 23rd, 2013, 10:44 pm

Re: g++ linker trouble with tkcmdsetCSAFE_init_protocol

Post by TheRocketeer » July 9th, 2013, 8:17 pm

For what it's worth, I get the exact same result if I convert my program to C and compile. It really doesn't make much sense to me: if it can't find the one symbol, why CAN it find all the rest? Perhaps it's not a problem with the SDK at all, but with the VC++ used to compile it?
"You can't outrun a donut." -- TomR

User avatar
kdahlhaus
500m Poster
Posts: 95
Joined: September 17th, 2006, 2:13 pm
Contact:

Re: g++ linker trouble with tkcmdsetCSAFE_init_protocol

Post by kdahlhaus » July 11th, 2013, 6:54 pm

I don't have an answer for your specific question, but here is my makefile in the hopes that it can help you out:

Code: Select all

C2INC=../sdk/PC
C2LIBDIR=../sdk/PC

PEXPORTS=pexports
DLLTOOL=dlltool

CFLAGS      =-mno-cygwin
SWIGFLAGS	=-strict 0 -c++ -shadow -dhtml
INCLUDES    = -I$(C2INC)
LDFLAGS     = -L$(C2LIBDIR)
LIBS        = -lRPPM3DDI -lRPPM3USB 

all:  libs test.exe testIntervals.exe testState.exe
#;PyErg.pyd

PyErg.pyd:
	swig -c++ -python PyErg.i 
	gcc -mno-cygwin -shared $(INCLUDES) -IC:\python24\include PyErg_wrap.cxx Pm3Erg.o ErgNet.o CsafeDll.o CIIHeaders.o ErgState.o $(LDFLAGS) -Lc:\Python24\libs  $(LIBS) -lpython24 -lstdc++ -o_PyErg.pyd
        

test.exe: test.o Pm3Erg.o ErgNet.o CSafeDll.o  CIIHeaders.o ErgState.o SlideRatio.o
	$(CXX)  $(CFLAGS)  $(INCLUDES) $(PYTHON_INCLUDES) $(LDFLAGS) -o test.exe $^ $(LIBS)

testIntervals.exe: testIntervals.o Pm3Erg.o ErgNet.o CSafeDll.o  CIIHeaders.o ErgState.o SlideRatio.o
	$(CXX)  $(CFLAGS)  $(INCLUDES) $(PYTHON_INCLUDES) $(LDFLAGS) -o testIntervals.exe $^ $(LIBS)

testState.exe: testState.o Pm3Erg.o ErgNet.o CSafeDll.o  CIIHeaders.o ErgState.o SlideRatio.o
	$(CXX)  $(CFLAGS)  $(INCLUDES) $(PYTHON_INCLUDES) $(LDFLAGS) -o testState.exe $^ $(LIBS)

 	
%.o : %.cpp
	$(CXX) $(CFLAGS) $(INCLUDES) $(PYTHON_INCLUDES) -c $< -o $@



.PHONY: clean
clean:
	rm -f *.o libRPPM3DDI.a libRPPM3CSAFE.a libRPPM3USB.a *.def *.exe _PyErg.pyd PyErg.py PyErg.pyc PyErg_wrap.cxx RPPM3DDI.DLL RPPM3USB.DLL RPPM3CSAFE.DLL

libs: libRPPM3DDI.a libRPPM3CSAFE.a libRPPM3USB.a
	echo


libRPPM3DDI.a:  RPPM3DDI.DLL
	$(PEXPORTS) $(C2LIBDIR)/RPPM3DDI.DLL > RPPM3DDI.def
	$(DLLTOOL) --dllname RPPM3DDI.dll --def RPPM3DDI.def --output-lib libRPPM3DDI.a

libRPPM3USB.a:  RPPM3USB.DLL
	$(PEXPORTS) $(C2LIBDIR)/RPPM3USB.DLL > RPPM3USB.def
	$(DLLTOOL) --dllname RPPM3USB.dll --def RPPM3USB.def --output-lib libRPPM3USB.a

libRPPM3CSAFE.a:  RPPM3CSAFE.DLL
	$(PEXPORTS) -o $(C2LIBDIR)/RPPM3CSAFE.DLL > RPPM3CSAFE.def
	$(DLLTOOL) --dllname RPPM3CSAFE.dll --def RPPM3CSAFE.def --output-lib libRPPM3CSAFE.a

RPPM3DDI.DLL: $(C2LIBDIR)/RPPM3DDI.DLL
	cp $(C2LIBDIR)/RPPM3DDI.DLL .

RPPM3USB.DLL: $(C2LIBDIR)/RPPM3USB.DLL
	cp $(C2LIBDIR)/RPPM3USB.DLL .

RPPM3CSAFE.DLL: $(C2LIBDIR)/RPPM3CSAFE.DLL
	cp $(C2LIBDIR)/RPPM3CSAFE.DLL .



.PHONY: runtest
runtest:
	export PATH=$(C2LIBDIR):$PATH;./test.exe 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://powertwenty.com
'Do' or 'Do not', there is no 'Try' -Yoda

Post Reply