- Revenera Community
- :
- FlexNet Publisher
- :
- FlexNet Publisher Forum
- :
- Re: How do I link C++ into a vendor daemon?
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I'd like to use C++ source code and libraries in a vendor daemon for Windows and Linux.
What do I need to do to achieve this?
Among other things, to do this we'd need to main() compiled as C++ rather than C and (in the case of gcc) to use g++ as the linker.
I don't see any support for this in the makefiles.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
That info may be out of date. I've never had a problem with this, and I do use static initialization for a couple variables. I think Revenera uses gcc so I'm at least using the same compiler vendor.
I found this link that suggests that the issue with main might be old (in the "Linking the Program" section) but I've never actually heard of this issue before. https://www.oracle.com/technical-resources/articles/it-infrastructure/mixing-c-and-cplusplus.html
You should probably just try it and see what happens.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
We do this. You need to modify the makefile. There probably isn't one simple change, though. We changed some instances of CC to CXX (and defined CC to be gcc, which may or may not be necessary). We also added some flags like -std=c++11 to one of the compile lines (but that was for compiling our own file). You don't need to change all the targets, just the DAEMON target. We didn't bother changing how lm_new or lsrvend were compiled.
The biggest issue is that you may need to ship the correct versions of the libstdc++ (and maybe libgcc_s) libraries on Linux. Your customers won't always have them, or the correct versions. To help with this we used the -rpath option when linking so that the vendor daemon would look in a specific relative directory, which is where we put the libraries.
We didn't need to change anything dealing with a main function. I think it is in one of the static libraries that you link with.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thanks for the info. Its good to know this is being done successfully.
What you say makes sense, but I'm concerned about https://isocpp.org/wiki/faq/mixing-c-and-cpp, which says "You must use your C++ compiler when compiling main()(e.g., for static initialization) ". In a vendor daemon, main() is already compiled and we don't have the source code.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
That info may be out of date. I've never had a problem with this, and I do use static initialization for a couple variables. I think Revenera uses gcc so I'm at least using the same compiler vendor.
I found this link that suggests that the issue with main might be old (in the "Linking the Program" section) but I've never actually heard of this issue before. https://www.oracle.com/technical-resources/articles/it-infrastructure/mixing-c-and-cplusplus.html
You should probably just try it and see what happens.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I certainly will.
Many thanks.
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)