View topic - linking a C program to C++ library with STL

linking a C program to C++ library with STL

anything that doesn't fit to other groups.

linking a C program to C++ library with STL

Postby rob.hoeye » Thu May 03, 2012 3:34 pm

I am trying to retrofit some C++ and STL functions into an existing QNX 6.3 C projects. I am encapsulating the C++ in a single library/project and referancing the "friend" functions via a C interface. This worked up till I included STL in the C++. Now my C projects (a C photon app and a cmdline C testapp, both include -lang-c++ in their common.mk LDFLAGS macro) spew errors about unresolved symbols, all with the signature "std::*". I assume that I need to forcably include a STL runtime library in each referancing projects configuration, but do not know its name or path. Also, nothing that looks like it could be the runtime library shows up wen I search the c:\QNX630 folder for "*stl*", just *stl*.h, *stl*.java and *stl*.html, no *stl*.a.

Thanks
Rob
rob.hoeye
New Member
 
Posts: 2
Joined: Thu May 03, 2012 2:50 pm

Re: linking a C program to C++ library with STL

Postby Tim » Thu May 03, 2012 5:00 pm

Rob,

A couple of things:

1) Something quick to try. In your C++ code that calls the STL functions, how are you referencing them? In other words do you have a std:: in front of the calls? gcc 2.9.5. didn't require it but gcc 3.3.1 does. I'm just wondering if maybe all you need is a 'using namespace std;' line in top of your C++ files.

2) Any chance you can just post your Makefile. That would make it a lot easier to see where you might have gone wrong. It doesn't sound like you have a problem since your app links with your own C++ code.

Tim
Tim
Senior Member
 
Posts: 1469
Joined: Wed Mar 10, 2004 12:28 am

Re: linking a C program to C++ library with STL

Postby rob.hoeye » Fri May 04, 2012 6:24 am

Tim:
Not sure what I did other than use the same version of gcc on both the library and the test application.

It all links now so I'm happy.
Thanks.
rob.hoeye
New Member
 
Posts: 2
Joined: Thu May 03, 2012 2:50 pm


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron