Help learning how to interface with c(++)

Kagamin spam at here.lot
Sat Mar 5 05:24:13 PST 2011


Kai Meyer Wrote:

> I can't seem to get this to work right:
> 
> gcc -m32 -shared -fPIC Test.cpp -o libTest.so
> g++ -m32 test_c.cpp -L. -lTest -o test_c
> wine htod.exe Test.h Test.d
> dmd test_d.d Test.d -L-L. -L-lTest -oftest_d
> test_d.o: In function `_Dmain':
> Test.d:(.text._Dmain+0x20): undefined reference to `increment'
> collect2: ld returned 1 exit status
> --- errorlevel 1
> make: *** [test_d] Error 1
> 
> The resulting test_c binary from g++ works as intented (With either 
> LD_LIBRARY_PATH="." or LD_RUN_PATH="."):
> $ ./test_c
> Count = 0
> Count = 1
> $ ldd test_c
> 	linux-gate.so.1 =>  (0x00ad1000)
> 	libTest.so (0x005b9000)

try non-shared libTest, dmd prefers single executable compilations.


More information about the Digitalmars-d-learn mailing list