Code::Blocks

User forums => Help => Topic started by: jpattee on August 12, 2005, 04:59:00 pm

Title: Compiling Dll and Lib in BCC
Post by: jpattee on August 12, 2005, 04:59:00 pm
I am using the borland compiler.  It compiles and links exe files OK.  It compiles dll and lib files OK but there is a problem with linking.

I have tried changing the registry entries but it has no effect.  CodeBlocks doesn't seem to be using the registry for these.

Linker message for the dll follows:

ilink32.exe    -L"C:\_jpFiles\Programs\CodeBlocks\Borland\BCC55\Lib" -L"C:\_jpFiles\Programs\CodeBlocks\Borland\BCC55\Lib\PSDK" -o "AStyle.dll"    obj\Astyle\src\ASCase.obj obj\Astyle\src\ASFormatter.obj obj\Astyle\src\ASResource.obj obj\Astyle\src\astyle_main.obj obj\Astyle\src\ASBeautifier.obj   
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Fatal: Unable to open file 'ASTYLE.DLL'
Process terminated with status 1 (0 minutes, 3 seconds)
1 errors, 34 warnings
 

Linker message for the static library follows.  The problem is the 'o' in 'obj'.  When I change this to something else, the unexpected char is always the first letter.

tlib.exe /C "lib\AStyle.lib" +obj\Astyle\src\ASCase.obj obj\Astyle\src\ASFormatter.obj obj\Astyle\src\ASResource.obj obj\Astyle\src\astyle_main.obj obj\Astyle\src\ASBeautifier.obj ,
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
Error: unexpected char 'o' in command line
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 34 warnings
 
Title: Re: Compiling Dll and Lib in BCC
Post by: rickg22 on August 12, 2005, 06:29:45 pm
OK um... define "using the registry". You got me confused in there.
Title: Re: Compiling Dll and Lib in BCC
Post by: jpattee on August 12, 2005, 09:15:58 pm
CodeBlocks has registry entries like "Link object files to static library" with a value of "$lib_linker /C $static_output +$link_objects,$def_output".  Changing these values didn't seem to change the command line.  For instance, I removed the + before "+$link_objects", but it was still there in the call to tlib.exe.
Title: Re: Compiling Dll and Lib in BCC
Post by: rickg22 on August 12, 2005, 10:05:14 pm
I guess you don't know you can change these settings in "Advanced compiler settings", don't you?
Title: Re: Compiling Dll and Lib in BCC
Post by: jpattee on August 12, 2005, 11:58:52 pm
Thanks, I didn't know that.

So...
What do I change to eliminate the errors?
Title: Re: Compiling Dll and Lib in BCC
Post by: rickg22 on August 13, 2005, 12:01:51 am
Um... try linking those particular files by hand - what we need is the format of the commandline used to invoke the compiler (or in this case, the linker). Try running "ilink32 /?" which will display a series of options. The trick is to modify the commandline in the settings so that it matches the one used by ilink32.
Title: Re: Compiling Dll and Lib in BCC
Post by: lymichri on August 13, 2005, 04:40:48 pm
Linker message for the static library follows.  The problem is the 'o' in 'obj'.  When I change this to something else, the unexpected char is always the first letter.

tlib.exe /C "lib\AStyle.lib" +obj\Astyle\src\ASCase.obj obj\Astyle\src\ASFormatter.obj obj\Astyle\src\ASResource.obj obj\Astyle\src\astyle_main.obj obj\Astyle\src\ASBeautifier.obj ,
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
Error: unexpected char 'o' in command line
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 34 warnings


For static linking change the template in "Advanced compiler settings" from

$lib_linker /C $static_output +$link_objects,$def_output

to

$lib_linker /C /P512 $static_output /a $link_objects.

The original definition doesn't work because the "+" has to be prepended for each object.
The optional /P512 option for the page size can be omitted, if you don't need it.
Title: Re: Compiling Dll and Lib in BCC
Post by: jpattee on August 15, 2005, 07:45:08 pm
Thanks to everyone for the response.

Something else has come up and it will probably be next week before I get back to this.  But I will try the fix to the static library the first chance I get.  I will post a reply of the results.

Meanwhile, if anyone knows a valid command line for linking a dll I would appreciate a response.  This is the first time I have worked with Borland and I am not familiar with the compiler and linker options.


Title: Re: Compiling Dll and Lib in BCC
Post by: jpattee on August 18, 2005, 11:03:49 pm
Here are the linker options that worked for me.

To link the static library, I changed the + to /a as per lymichri above.  It worked.  The settings I used for "Link object files to static library" are:

$lib_linker /C $static_output /a $link_objects,$def_output


A dynamic library uses the same link program as an executable, so the command line format has to be the same.  I modified the executable command line by adding -Tpd and changing c0w32 to c0d32.   The settings I used for "Link object files to dynamic library" are:

$linker -Tpd $link_options $libdirs c0d32 $link_objects, $exe_output,, $libs,, $link_resobjects