Author Topic: building a static lib: problems with ar  (Read 8064 times)

leumi

  • Guest
building a static lib: problems with ar
« on: May 22, 2007, 12:17:16 am »
hello.

i am new to C::B.

i tried to build a simple static library with code::blocks. the code is written in d-language, but this shouldn't make any difference, because the problem affects the object file "testlib.o".

when the code is compiled C::B uses "ar" to build the final file "libtestlib.a"
but, somehow C::B uses the command "ar" in the wrong way: i get the following error-message:

Compiling: testlib.d
Linking static library: libTestlib.a
ar: illegal option -- T
Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...
       ar -M [<mri-script]
 commands:
  d            - delete file(s) from the archive
  m[ab]        - move file(s) in the archive
  p            - print file(s) found in the archive
  q[f]         - quick append file(s) to the archive
  r[ab][f]  - replace existing or insert new file(s) into the archive
  t            - display contents of archive
  x
  •          - extract file(s) from the archive

 command specific modifiers:
  [a]          - put file(s) after [member-name]
            - put file(s) before [member-name] (same as )
  [N]          - use instance [count] of name
  [f]          - truncate inserted file names
  [P]          - use full path names when matching
 
  •           - preserve original dates
          - only replace files that are newer than current archive contents
 generic modifiers:
  [c]          - do not warn if the library had to be created
            - create an archive index (cf. ranlib)
            - do not build a symbol table
  [v]          - be verbose
  [V]          - display the version number
  @<file>      - read options from <file>
 emulation options:
  No emulation specific options
ar: supported targets: elf32-i386 a.out-i386-linux efi-app-ia32 elf32-little elf32-big elf64-x86-64 elf64-little elf64-big srec symbolsrec tekhex binary ihex trad-core


why does c::b use the option "--T"? the command ar doesen't have this option.
whatcan i do to get my static library work?

i'd be very thankfull for any help!


ps: the source code: "libtest.d" (it's very smal. just for testing)

module testlib;
import std.stdio;

void add(int i1, int i2)
{
   writefln("Greetings from your lib:",i1 + i2,"\n");
   return 0;
}


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: building a static lib: problems with ar
« Reply #1 on: May 22, 2007, 01:48:37 am »
Please cleanup the post so it is readable.

Please turn on Full Command Line Logging and post the command causing the error.

Steps to turn on Compiler Logging in Nightly Build:
"Settings" -> "compiler debugger"
Change "Compiler Settings" to "Other Settings"
Set "Compiler Logging" to "Full Command Line"

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

leumi

  • Guest
Re: re: building a static lib: problems with ar
« Reply #2 on: May 22, 2007, 07:50:21 pm »
ok. thank you.

the following command causes the error:

ar libTestlib.a  obj/Release/testlib.o


it results in this error message:

ar: illegal option -- T
Usage: ar [emulation options] [ - ]{dmpqrstx}[ abcfilNoPsSuvV ] [ member-name ] [ count ] archive-file file...
       ar -M [ <mri-script ]
 commands:
  d            - delete file(s) from the archive
  m[ ab ]        - move file(s) in the archive
  p            - print file(s) found in the archive
        .
        .
        .
ar: supported targets: elf32-i386 a.out-i386-linux efi-app-ia32 elf32-little elf32-big elf64-x86-64 elf64-little elf64-big srec symbolsrec tekhex binary ihex trad-core
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings



i don't understand this error message. the option " -- T " is not used by c::b


i hope someone can help me.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: building a static lib: problems with ar
« Reply #3 on: May 22, 2007, 09:35:05 pm »
Try running the "bad command" in an cmd window and see if you get the error there.

Also, try do the following command and post results.
Code
ar --version
Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: re: building a static lib: problems with ar
« Reply #4 on: May 22, 2007, 10:18:04 pm »
Is there a space character between the "lib" and the "Testlib.a" part of that filename?

the following command causes the error:

ar libTestlib.a  obj/Release/testlib.o

-- Ringo

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: building a static lib: problems with ar
« Reply #5 on: May 22, 2007, 10:36:40 pm »
What version of Code::Blocks are you using?
RC2 or Nightly Build?
If Nightly Build, what is the svn number?
If RC2, I suggest upgrading to Nightly Build.

The problem appears to be an Code::Blocks issue, but I don't see it with the current nightly build.

What OS are you running? Win9X, WinXP, Linux and others?

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: building a static lib: problems with ar
« Reply #6 on: May 23, 2007, 12:06:20 am »
I believe C::B should be using something like "ar -r -s libTestlib.a obj/Release/testlib.o". Check in the advanced compiler options (global compiler settings, "other settings" tab, "Advanced options" button) to make sure that the "Link object files to static library" command is set appropriately -- on my (WinXP) machine it's "$lib_linker -r -s $static_output $link_objects".
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)