I'm creating dynamic libraries with codeblocks SVN 7141.
In project properties / Build Targets, I choose Type = Dynamic Library
To be able to link with this lib, I must create a .a (MinGW) or .lib (Visual) and check "Create import library"
ok, no problem.
In the field import library filename I change $(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME) by lib\$(TARGET_OUTPUT_BASENAME)
to be able to write the lib (.a) into the project folder under "lib" directory.
1> If the lib folder doesn't exists, it is not created automatically, why ? So, I must create lib folder and it's work.
2> I save all (project / workspace / files / etc) and quit Code::Blocks.
3> Run Codeblocks and re-open workspace / projetc.
4> In the field import library filename there is no change: it left $(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME) and no lib\$(TARGET_OUTPUT_BASENAME) so this option is not saved properly.
Any idea ?
You misunderstood the option. "import library filename" does really ONLY mean the file's name, not including a path. To setup the path you need to change the "output filename" accordingly (the one where you can actually pick a file with the "..." button).
If you are unsure, leave the filed "import file name" as it is.
Thanks for your reply.
Imagine, I have a /RootWorkspace/FooProject
If I want to generate a dynamic library foo into ../bin/Debug/foo.dll (so in /RootWorkspace/bin/Debug/foo.dll)
and a library file (.a) into FooProject/lib/foo.a
How I can do ? Is it possible or the dll file and .a are always generated at the same place ?
Because I a several dll / exe and I want to link all executable into ../bin/Debug (or release) directory and let all lib into their respective folder project path.
Quote from: Feneck91 on May 17, 2011, 05:02:17 PM
If I want to generate a dynamic library foo into ../bin/Debug/foo.dll (so in /RootWorkspace/bin/Debug/foo.dll)
and a library file (.a) into FooProject/lib/foo.a
How I can do ?
You can only do, what the compiler allows to do. GCC does not allow that.
So: EITHER you put everything in
../bin/Debug/, add this path to the linker options and remove the export libraries for distribution OR you create everything in
FooProject/lib/ and copy the DLL to
../bin/Debug/ in a post build step (probably using macros to make it more generic).
I thought like you, so I create everything in FooProject/lib/ and copy the DLL to ../bin/Debug/ in a post build step but in DOS MODE (copy).
What is macro ? Is it possible to make generic copy (not depending on target plateform ?
Quote(probably using macros to make it more generic).
What kind of macros ?
I use to copy wxWidgets dll from to bin\output\ I use script like :
[[IO.CopyFile(_("$(#wx)/lib/gcc_dll/wxmsw$(#wxver)ud_gcc.dll"), _("../bin/$(output)/wxmsw$(#wxver)ud_gcc.dll"),false);]]
But it always as me if it is confidence or not... Not really cool to use. Another way ?
Quote from: Feneck91 on May 17, 2011, 10:23:32 PM
[[IO.CopyFile(_("$(#wx)/lib/gcc_dll/wxmsw$(#wxver)ud_gcc.dll"), _("../bin/$(output)/wxmsw$(#wxver)ud_gcc.dll"),false);]]
But it always as me if it is confidence or not... Not really cool to use. Another way ?
Sure. You can use plain (Win32-)SHELL commands, like
xcopy or just
copy. With macros I meant making use of e.g. $(TARGET_OUTPUT_FILE) or alike...
For example: I've a project that compiles the DLL's and link libs in a .lib folder. Then I setup a batch "make copy.bat" file like this:
@echo off
if not exist "%1" goto PluginNotFound
if "%2"=="" goto MissingPluginName
if exist "..\%2.dll" (
rem copy the file only, if the ARCHIVE flag is set
rem (avoid copying if file is unchanged)
echo Updating %2...
rem D: Only newer files (by date)
rem M: Copy on / and reset archive attribute
rem Y: Answer queries about overwriting with "Yes"
xcopy "%1" .. /D /M /Y
)
if not exist "..\%2.dll" (
echo Copying %2...
copy "%1" ..
)
goto TheEnd
:PluginNotFound
echo Error: Plugin not found.
goto TheEnd
:MissingPluginName
echo Error: Name of the plugin not provided.
goto TheEnd
:TheEnd
As a post-build step I can then use:
make_copy.bat $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_BASENAME)...for all plugin DLL's I'd like to copy.
Notice that you would need to adjust the path ("
..") in the batch file accordingly, so it matches your setup.
Here is what works for me. Say I have a 'fubar' project in
projects\fubar\
where the 'fubar.cbp' resides. Then I create a 'dynamic dll' target and set the output filename to
bin\Debug\foo.dll
and the import library filename to
lib\$(TARGET_OUTPUT_BASENAME)dbg
.The lib folder must be created before building the target.
After I build the target I have a 'foo.dll' in
fubar\bin\debug\
folder and a 'libfoodbg.a' in
fubar\lib\
folder as I want them and set them to be. But when I restart CB import library filename setting reverts back to
$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME)
and make me lose the setting. The linker can definitely create the target dll and the import library in different folders so I don't get what doesn't work here to make this setting not saved?
OS: Win 7
CB: svn 7173, May 28 Nightly
MinGW GCC: v4.5.2