Hi!
I have a project, and I want that the source code of this project can be compiled as .lib file or .dll file. How do I do this?
I think that I should use # ifdef and stuff like that, but I don't know how to declare that.
Hi!
I have a project, and I want that the source code of this project can be compiled as .lib file or .dll file. How do I do this?
I think that I should use # ifdef and stuff like that, but I don't know how to declare that.
Current projects:
1) User Interface Development Kit (C++)
2) HTML SDK (C++)
3) Classes (C++)
4) INI Editor (Delphi)
Well you create a lib project and a dll project
You add all your source files to both of them
You tweak the code so that the lib project builds correctly
You then try and tweak the code so that the dll project builds correctly, but any changes you make are put inside conditional compilation
Say, for the sake of argument, that something should be static in a lib, but extern in a dll, then you would do this
Then you edit the dll project, and in the 'additional pre-processor switches', you add BUILDING_DLLCode:#if BUILDING_DLL /* stuff you want for dll builds */ extern int var; #else /* stuff you want for lib builds */ static int var; #endif /* stuff common to both */ void foo ( void ) { var = 1; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.