Click here to Skip to main content
14,421,922 members
Rate this:
Please Sign up or sign in to vote.
Hi,

I have a c++ program that compiles to a dll.

When i open the dll in a text editor i noticed that in some part of the dll i can actually see a full path to the source files i.e c:\myproject\myfile.h

I have noticed that this happens when i use macro in my code with __FILE__ and when using 3rdparty projects such as boost or opencv

Is there any way that i can prevent the full file path to be written to the dll?

Thanks,
Ron
Posted
Updated 27-Apr-15 4:29am
v2
Comments
   
Normally, should be no trace of source files at all. How can I know how can you put them in?
—SA
Rate this:
Please Sign up or sign in to vote.

Solution 1

When you are using predefined macros like __FILE__ the compiler (at the pre-processing stage) puts the evaluated value of the macro in the binary created. For __FILE__ that value is the full path to the file as loaded by the pre-processor...

If you do not want to see it don't use it or use it only in debug mode and hide (with #define and #ifdef) when compiling for release...
   
v3
Comments
babbbam 27-Apr-15 9:36am
   
Thanks for the answer @KornfeldEliyahuPeter, however as i mentioned, i am using 3rdparty such as boost and opencv and they are outputing the full path to the dll...
Kornfeld Eliyahu Peter 27-Apr-15 10:05am
   
It is possible that you are using a statically linked version of the 3rd party and __FILE__ used there so it becomes part of your code...
Rate this:
Please Sign up or sign in to vote.

Solution 2

you must build the dll in release mode. Check the compiler settings in your project.

In a release build these macro should not get compiled in the binary output.

Maybe you should look WHERE the release dll is build. :-O
   
Comments
Kornfeld Eliyahu Peter 27-Apr-15 9:32am
   
That's not enough - if you use these macros in code that are part of the release code it still will be there...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100