Author Topic: C::B adds options to lib.exe (-r ; ranlib ) that i can not remove.  (Read 177 times)

Offline BDick

  • Single posting newcomer
  • *
  • Posts: 5
I want to make a static library for windows with the PGI compiler. Compiling and linking of executables with pgfortran works fine, but the built of the library fails. In "settings" the toolchain is set so that "C-compiler", "C++ compiler", and "linker for dynamic libs" all point to pgfortran.exe, and "linker for static libs" points to the lib.exe from Microsoft.

The correct call should be: lib.exe name.o
and generates name.lib

I test this in a command shell.
However, C::B issues the command: lib.exe -r name.a name.o ranlib name.a

How can I tell C::B to omit "-r name.a" and "ranlib name.a"? In the varous dialog boxes I can ADD more options, but I can apparently not REMOVE those superfluous ones.

best regards,
Bernhard

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6430
    • My Best Post
Re: C::B adds options to lib.exe (-r ; ranlib ) that i can not remove.
« Reply #1 on: February 13, 2019, 11:20:16 pm »
Copy a compiler then edit the advanced compiler options.

This is what Command: Link Object files to static library shows for "PGI Fortran Compiler"
Code: [Select]
$lib_linker -r $static_output $link_objects
ranlib $exe_output

Tab: Other Settings Button: Advanced Options
« Last Edit: February 14, 2019, 05:17:46 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BDick

  • Single posting newcomer
  • *
  • Posts: 5
Re: C::B adds options to lib.exe (-r ; ranlib ) that i can not remove.
« Reply #2 on: February 14, 2019, 10:17:27 am »
Thank you very much, with your help I could solve the problem (so I think). In case somebody has a similar problem, here is what I did:

There are two versions of the file "options_pgifortran.xml" on the computer:
one here:           C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\compilers
the second here: C:\Users\dib05004\AppData\Roaming\CodeBlocks\share\codeblocks\compilers

only changes to the second (after making a backup copy) seems necessary.
I changed:

  <Program name="LIB" value="C:\Program Files\PGICE\win64\18.4\bin\ar.exe"/>
  <Switch name="libExtension" value="a"/>
  <Command name="LinkStatic" value="$lib_linker -r $static_output $link_objects&#xA;&#x9;ranlib $exe_output"/>

into:

  <Program name="LIB" value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\lib.exe"/>
  <Switch name="libExtension" value="lib"/>
  <Command name="LinkStatic" value="$lib_linker  $link_objects $libs /OUT:$exe_output"/>

The first change points to the library manager of Microsoft for x64 host and x64 code. The third invoces this with the correct option for setting the output file name. I found the second change necessary, since otherwise the library gets the extension "a", regardless of what one sets in the "Project Properties -> target" dialog.

Hence, many thanks!
« Last Edit: February 14, 2019, 10:31:40 am by BDick »

Offline Miguel Gimenez

  • Almost regular
  • **
  • Posts: 204
Re: C::B adds options to lib.exe (-r ; ranlib ) that i can not remove.
« Reply #3 on: February 14, 2019, 11:39:40 am »
Thank you for the information, but direct editing of the XML files is not a good idea; Using the Global Compiler Settings is a lot easier and less prone to errors.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11474
    • Travis build status
Re: C::B adds options to lib.exe (-r ; ranlib ) that i can not remove.
« Reply #4 on: February 15, 2019, 06:39:07 pm »
If the default settings are wrong you should provide a patch, so it would work fine by default.

@darmar: Do you know if this is something we need to fix?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6430
    • My Best Post
Re: C::B adds options to lib.exe (-r ; ranlib ) that i can not remove.
« Reply #5 on: February 15, 2019, 06:58:29 pm »
I am downloading pgi-community-windows-x64 of the compiler; I will see if it installs.
Be about 6 hours just to do the download of the 1 1/2 gig installer.

I think this is the second person with this issue; that I have replied to the post.
But, it was a long time ago with the last one. Did not see a free download on the last one.

Edit: I am still several hours from finishing download; I had to restart from the beginning.
Edit2: Installer refused to install; likely a corrupted download.

Tim S.
« Last Edit: February 16, 2019, 05:27:32 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org