Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

Error linking with C code

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

Hi All,

I am writing pascal wrapper for a C library called "CTP", which is used in future trading. My project is here:

https://github.com/xrfang/CTPas

Compiling the interface file along is successful. While linking, fpc complains:

./thostmduserapi.so, needed by ./libthost.so, not found (try using -rpath or -rpath-link)

while libthost.so is my wrapper writting in C, which uses thostmduserapi.so, provided by the vendor (no source code).

Full error output is:

Free Pascal Compiler version 2.6.2 [2013/03/17] for x86_64 Copyright (c) 1993-2012 by Florian Klaempfl and others Target OS: Linux for x86-64
Compiling demo.pas
Linking demo
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/bin/ld: warning: ./thostmduserapi.so, needed by ./libthost.so, not found (try using -rpath or -rpath-link)
./libthost.so: undefined reference to
`CThostFtdcMdApi::CreateFtdcMdApi(char const*, bool, bool)' demo.pas(4,1) Error: Error while linking
demo.pas(4,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)

Could you please explain how to solve this problem?

Thanks!
Xiangrong

Michael Van Canneyt
to Xiangrong Fang
Xiangrong Fang wrote 10 lines
Hi All, I am writing pascal wrapper for a C library called "CTP", which is used in future trading.  My project is here: https://github.com/xrfang/CTPas Compiling the interface file along is successful. While linking, fpc complains: ./thostmduserapi.so, needed by ./libthost.so, not found (try using -rpath or -rpath-link) while libthost.so is my wrapper writting in C, which uses thostmduserapi.so, provided by the vendor (no source code).

where is thostmduserapi.so ?

Michael.

Show quoted text 22 lines
Full error output is: Free Pascal Compiler version 2.6.2 [2013/03/17] for x86_64 Copyright (c) 1993-2012 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling demo.pas Linking demo /usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/bin/ld: warning: ./thostmduserapi.so, needed by ./libthost.so, not found (try using -rpath or -rpath-link) ./libthost.so: undefined reference to `CThostFtdcMdApi::CreateFtdcMdApi(char const*, bool, bool)' demo.pas(4,1) Error: Error while linking demo.pas(4,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled) Could you please explain how to solve this problem? Thanks! Xiangrong
Michael Van Canneyt
to Xiangrong Fang
Xiangrong Fang wrote 7 lines
where is thostmduserapi.so ? Michael. This file is under libthost folder, I copied it to pasintf folder then use fpc to compile demo.pas.

I think you should try to pass the name of the folder where libthost is to the linker. -FL/path/to/libthost

Michael.

Xiangrong Fang
to Michael Van Canneyt
Show quoted text 7 lines
I think you should try to pass the name of the folder where libthost is to the linker. -FL/path/to/libthost Michael.

This does not work, same error message. I also tried to copy libthost.so to current dir, but leave thostmduserapi.so in ../libthost, same result.

Regards,
Xiangrong