Author Topic: Import library filename not work / not saved !  (Read 13277 times)

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
Import library filename not work / not saved !
« on: May 17, 2011, 02:44:22 pm »
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 ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Import library filename not work / not saved !
« Reply #1 on: May 17, 2011, 02:59:47 pm »
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
Re: Import library filename not work / not saved !
« Reply #2 on: May 17, 2011, 05:02:17 pm »
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.
« Last Edit: May 17, 2011, 05:05:03 pm by Feneck91 »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Import library filename not work / not saved !
« Reply #3 on: May 17, 2011, 08:42:20 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).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Feneck91

  • Multiple posting newcomer
  • *
  • Posts: 112
Re: Import library filename not work / not saved !
« Reply #4 on: May 17, 2011, 10:23:32 pm »
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 :
Code
[[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 ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Import library filename not work / not saved !
« Reply #5 on: May 18, 2011, 09:12:13 am »
Code
[[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:
Code
@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.
« Last Edit: May 18, 2011, 09:14:16 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline scarphin

  • Lives here!
  • ****
  • Posts: 640
Re: Import library filename not work / not saved !
« Reply #6 on: June 02, 2011, 01:59:53 am »
Here is what works for me. Say I have a 'fubar' project in
Code
projects\fubar\
where the 'fubar.cbp' resides. Then I create a 'dynamic dll' target and set the output filename to
Code
bin\Debug\foo.dll
and the import library filename to
Code
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
Code
fubar\bin\debug\
folder and a 'libfoodbg.a' in
Code
fubar\lib\
folder as I want them and set them to be. But when I restart CB import library filename setting reverts back to
Code
$(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