Author Topic: How to build dll on win32  (Read 8365 times)

siomek

  • Guest
How to build dll on win32
« on: May 19, 2006, 04:46:23 pm »
Hello,

I tried many times build dll library, but I have a lot of problems. With build static library there are no problems. Are there any rules for build dll library for win32? Have I to add any dependencies?

Offline Defender

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: How to build dll on win32
« Reply #1 on: May 19, 2006, 04:53:40 pm »
If you describe, what your problem is, we could help you  :)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to build dll on win32
« Reply #2 on: May 19, 2006, 05:18:32 pm »
You are probably not asking about choosing "DLL" from the combobox in build options, I assume.

If your problems are due to missing symbols, you are very likely programming in C++ and are a victim to name mangling. In that case, add extern "C", and you'll be fine :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

siomek

  • Guest
Re: How to build dll on win32
« Reply #3 on: May 19, 2006, 07:16:43 pm »
I did that on sequence (build FANN library, http://leenissen.dk/fann/ ) :

1. File->New Project->Dynamic Link Library (options: Do not create any files). Project named fann_dll (simple :-))
2. On Managment->Projects->Workspace->fann_dll->Add files. I've added *.c and *.h files.
3. Build->Rebuild.

The log is:

-------------- Build: default in fann_dll ---------------
Compiling: ..\..\include\doublefann.c
Compiling: ..\..\include\fann.c
Compiling: ..\..\include\fann_cascade.c
Compiling: ..\..\include\fann_error.c
Compiling: ..\..\include\fann_io.c
Compiling: ..\..\include\fann_train.c
Compiling: ..\..\include\fann_train_data.c
Compiling: ..\..\include\fixedfann.c
Compiling: ..\..\include\floatfann.c
Linking dynamic library: fann_dll.dll
.objs\include\fann.o(.text+0x0):fann.c: multiple definition of `fann_create_standard'
.objs\include\doublefann.o(.text+0x0):doublefann.c: first defined here
.objs\include\fann.o(.text+0xc9):fann.c: multiple definition of `fann_create_sparse'
.objs\include\doublefann.o(.text+0xc9):doublefann.c: first defined here
.objs\include\fann.o(.text+0x9a8):fann.c: multiple definition of `fann_create_shortcut'
.objs\include\doublefann.o(.text+0x9b7):doublefann.c: first defined here
.objs\include\fann.o(.text+0xdd7):fann.c: multiple definition of `fann_run'
.objs\include\doublefann.o(.text+0xdec):doublefann.c: first defined here
.objs\include\fann.o(.text+0x1a62):fann.c: multiple definition of `fann_randomize_weights'
.objs\include\doublefann.o(.text+0x1b58):doublefann.c: first defined here
.objs\include\fann.o(.text+0x1ad9):fann.c: multiple definition of `fann_print_connections'
.objs\include\doublefann.o(.text+0x1be3):doublefann.c: first defined here
.objs\include\fann.o(.text+0x1d65):fann.c: multiple definition of `fann_init_weights'
.objs\include\doublefann.o(.text+0x1e6f):doublefann.c: first defined here
.objs\include\fann.o(.text+0x2009):fann.c: multiple definition of `fann_print_parameters'
.objs\include\doublefann.o(.text+0x2113):doublefann.c: first defined here
.objs\include\fann.o(.text+0x23b0):fann.c: multiple definition of `fann_get_num_input'
.objs\include\doublefann.o(.text+0x24c0):doublefann.c: first defined here
.objs\include\fann.o(.text+0x23ef):fann.c: multiple definition of `fann_get_total_connections'
.objs\include\doublefann.o(.text+0x24ff):doublefann.c: first defined here
.objs\include\fann.o(.text+0x23bb):fann.c: multiple definition of `fann_get_num_output'
.objs\include\doublefann.o(.text+0x24cb):doublefann.c: first defined here
.objs\include\fann.o(.text+0x23c6):fann.c: multiple definition of `fann_get_total_neurons'
.objs\include\doublefann.o(.text+0x24d6):doublefann.c: first defined here
.objs\include\fann.o(.text+0xa4e):fann.c: multiple definition of `fann_create_shortcut_array'
.objs\include\doublefann.o(.text+0xa5d):doublefann.c: first defined here
.objs\include\fann.o(.text+0x2930):fann.c: multiple definition of `fann_allocate_connections'
.objs\include\doublefann.o(.text+0x2a4b):doublefann.c: first defined here
.objs\include\fann.o(.text+0x184e):fann.c: multiple definition of `fann_destroy'
.objs\include\doublefann.o(.text+0x1944):doublefann.c: first defined here
.objs\include\fann.o(.text+0x2832):fann.c: multiple definition of `fann_allocate_neurons'
.objs\include\doublefann.o(.text+0x294b):doublefann.c: first defined here
.objs\include\fann.o(.text+0x23fa):fann.c: multiple definition of `fann_allocate_structure'
.objs\include\doublefann.o(.text+0x250a):doublefann.c: first defined here
.objs\include\fann.o(.text+0x29c1):fann.c: multiple definition of `fann_seed_rand'
.objs\include\doublefann.o(.text+0x2adc):doublefann.c: first defined here
.objs\include\fann.o(.text+0x176):fann.c: multiple definition of `fann_create_sparse_array'
.objs\include\doublefann.o(.text+0x176):doublefann.c: first defined here
.objs\include\fann.o(.text+0xa6):fann.c: multiple definition of `fann_create_standard_array'
.objs\include\doublefann.o(.text+0xa6):doublefann.c: first defined here
.objs\include\fann_cascade.o(.text+0x0):fann_cascade.c: multiple definition of `fann_print_connections_raw'
.objs\include\doublefann.o(.text+0x8a59):doublefann.c: first defined here
.objs\include\fann_cascade.o(.text+0x6a):fann_cascade.c: multiple definition of `fann_cascadetrain_on_data'
.objs\include\doublefann.o(.text+0x8ac3):doublefann.c: first defined here
.objs\include\fann_cascade.o(.text+0x2a9):fann_cascade.c: multiple definition of `fann_cascadetrain_on_file'
.objs\include\doublefann.o(.text+0x8d02):doublefann.c: first defined here
.objs\include\fann_cascade.o(.text+0x54b):fann_cascade.c: multiple definition of `fann_reallocate_connections'
.objs\include\doublefann.o(.text+0x8fa4):doublefann.c: first defined here
.objs\include\fann_cascade.o(.text+0x6e1):fann_cascade.c: multiple definition of `fann_reallocate_neurons'
.objs\include\doublefann.o(.text+0x913a):doublefann.c: first defined here
Process terminated with status 1 (0 minutes, 6 seconds)
52 errors, 0 warnings

The same project made for static library I've builded successfully. I was the same problems with other libraries.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to build dll on win32
« Reply #4 on: May 19, 2006, 08:25:34 pm »
I did that on sequence (build FANN library, http://leenissen.dk/fann/ ) :
What I did was:
- downloaded FANN (the fann-2.0.0.zip file - the sources)
- imported the workspace from the "MicrosoftVisualC++6.0" folder
- clicked "Build workspace"
...and everything works properly (using MinGW on Win32).
With regards, Morten.

Edit: According to the sources that are imported that way I wonder why you compile "doublefann.c", too? This is not part of the workspace...?!
« Last Edit: May 19, 2006, 08:27:51 pm 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 thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to build dll on win32
« Reply #5 on: May 19, 2006, 09:59:12 pm »
Getting lots and lots of "multiple definition of..." errors usually happens when you accidentially link with both the object files and a static library.

Probably you have built the static library first, and now you're linking the DLL, and the static lib is in the linker's options, too. Thus, the linker first links all the individual object files, and then again the static library, which of course has the very same symbols.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

siomek

  • Guest
Re: How to build dll on win32
« Reply #6 on: May 20, 2006, 04:43:17 pm »
...and everything works properly (using MinGW on Win32).

1. Yes, it works. But MSVC++ builts static lib, not dynamic lib.

Edit: According to the sources that are imported that way I wonder why you compile "doublefann.c", too? This is not part of the workspace...?!

2. Yes, my mistake. I removed unnecessary files. Now, it works. Thanks. It builds dll lib.

Getting lots and lots of "multiple definition of..." errors usually happens when you accidentially link with both the object files and a static library.
Probably you have built the static library first, and now you're linking the DLL, and the static lib is in the linker's options, too. Thus, the linker first links all the individual object files, and then again the static library, which of course has the very same symbols.

3. My mistake. I removed unnecessary files and CB builds dll lib. Thaks very much for help.