123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|407|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Ugh... importing classes from a DLL?!

Sun, 13 Dec 2009, 16:49
Afr0
I've made a DLL in C++ with three classes that inherits one other class.
I've exported them all using _declspec(dllexport)

Now... how do I load those classes from the dll so I can use 'em in my client application?!
I have a feeling it might be easier to create a library instead of a dll.
Is it possible to link to the library without including it into the executable file?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 14 Dec 2009, 00:53
Afr0
I tried compiling AssetManager as a static library instead, but now the linker throws 54 errors at me, of the type:



-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 14 Dec 2009, 01:00
Jayenkai
Looks like you replicated a function name, or something..
Try shoving afr0 to all your dll/library function names.

-=-=-
''Load, Next List!''
Mon, 14 Dec 2009, 02:06
Afr0
Yeah, well, I managed to get it down to 16 linker errors by now. The problem is with the Dark GDK I think. I'm linking to it for my executable, but it's using alot of functions that I think are also used by my library.
You can't shove afr0 to standard library classes!

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 14 Dec 2009, 02:11
Jayenkai
Oh, I thought it was your own stuff. *shrugs*

I've always trusted code, more than libraries, you get less of this horrible mismash of modern stuff. Libraries had value when they first started, but the second people started releasing different versions of the same library, and everyone started having all those different versions on their harddrive, the whole thing got completely screwed up.

If you can do a simpler import/include, I'd do that.
Best to have it in there, than break because it's not!

-=-=-
''Load, Next List!''
Mon, 14 Dec 2009, 02:34
Afr0
My library for dealing with The Sims Online archives is my own. But I think it's the Dark GDK library that's causing trouble.
Yeah, I'm seriously considering just using my classes as they are. :|

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 14 Dec 2009, 08:31
Phoenix
To solve the linker problems, try changing the 'Code Generation' option to be the /MTd for both of your projects.

Why don't you want the library to inhere within your executable? The total size of the program will be the same, regardless of how you split it. It's not possible to load a static library dynamically. That's what makes it static: you bake it into the executable at compile-time.
Mon, 14 Dec 2009, 09:02
JL235
You can also get (slightly) better performance with a static library because it's loaded with the program in one at startup.
Mon, 14 Dec 2009, 09:39
Afr0
I've experimented with the code generation, and the most I can get it down it is 8 linker errors. I've removed msvctrd.lib, because I read that linking the DarkGDK required you to do that.



If I include msvctrd.lib, I get 13 errors.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 14 Dec 2009, 10:33
Phoenix
DarkGDK is probably linking to the CRT dynamically, so try /MDd for the projects instead.

|edit| This suggestion is probably quite pointless, since it in all likeliness is what you started out with. It's a bit hard to solve by just looking at the errors, though. Try Googling for information, fiddle about. That's the best way to fix it. |edit|
Wed, 16 Dec 2009, 17:30
mindstorm8191
Not to diss anyone's work, but this is what I hate so much about C/C++. You can't simply attach a file to your program - you have to work it out with the linker, write a header file, and then it still might not work. I've got no idea how much work it'd take to get multiple DLL's working together. Why can't they just make it easy?
(end-rant)

-=-=-
Vesuvius web game
Thu, 17 Dec 2009, 10:24
Phoenix
Because it's a language which was designed almost 30 years ago. It is an outmoded way of doing things, but C++ is extremely rigid by now and the compilation model can't simply change.

However, most linker errors stem from either:
1. Incompatible character sets (Unicode vs. Multi-byte)
2. Static/dynamic linking to the CRT (/MD vs. /MT)
If tweaking those don't work, Google usually gives some results. In the remaining cases it is a pain.