Static lib linking - similar functions

Jun 29, 2011 at 7:00pm
Hello,

I just have a fairly quick question. The program I'm working on has a DLL that I would like to link to statically. I really don't have the option of using a DLL on the various platforms I tinker with.

The problem is that the program and the DLL both have some functions with the same name. That isn't a problem using EXE/DLL, but breaks the compile when linking to it statically using a lib instead. There are a few functions like that and they are pretty heavily scattered throughout the App/DLL which means lots and lots of renames.

If I rename them all, everything plays nice and I can do either DLL or LIB, but I would really like to not have to rename every other line if at all possible to make updating the App/DLL a bit easier when updates become available (I'm not the original author of either).

App:
void ReadConfig() //read in the app config file
void WriteConfig() //write out the app config file

DLL:
void ReadConfig() //read in the dll config file
void WriteConfig() //write out the dll config file

Any tips/suggestion on how I could keep them from conflicting?

Thanks
Last edited on Jun 29, 2011 at 7:02pm
Jun 29, 2011 at 7:30pm
You could use a namespace.
Jun 29, 2011 at 7:44pm
I assume you are on Windows. Find out if it has an equivalent of the *nix strip command. Compile the DLL to a static library and then strip out the symbols that are causing the problem. Or even better, strip everything that you don't need to link with the executable.
Jun 29, 2011 at 7:58pm
my thought was the same as Zhuge. use a namespace thats what they are for.
Jun 30, 2011 at 11:24pm
Ok, I'm going to try that and see what happens.

I don't suppose there's a way to set the namespace for the entire lib globally? Kind of like what root namespace implies. Or would it be better to just namespace the conflicted functions? I would like to keep the source as close to original as possible.

There's an older version of the app that's in C instead of CPP and I'm thinking about doing that one as well. Just wondering if that would still apply? I don't have much experience with namespaces. I rarely even come across them other than the common "std". So I have some reading up to do. Any articles or what not that's similar to what I'm trying to do would be very helpful.

Thanks again.
Topic archived. No new replies allowed.