I'm trying to use a DLL that is generated from one of my projects. When I try to compile I get alot of linker errors from ONE of the files from the DLL project. What I think is the problem is that I should be linking to the .lib file that the DLL project generates in order to create the DLL, but I can't find it anywhere in the project folder. Can anyone help me? I'm probably just confused about how to use DLLs to do implicit linking.

Here are some of the errors:

Linking...
entitylist.obj : error LNK2001: unresolved external symbol "void __cdecl Q_memcpy(void *,void *,int)" (?Q_memcpy@@YAXPAX0H@Z)
event.obj : error LNK2001: unresolved external symbol "void __cdecl Q_memcpy(void *,void *,int)" (?Q_memcpy@@YAXPAX0H@Z)
loader.obj : error LNK2001: unresolved external symbol "void __cdecl Q_memcpy(void *,void *,int)" (?Q_memcpy@@YAXPAX0H@Z)
error.obj : error LNK2019: unresolved external symbol "char * __cdecl Q_format(char *,...)" (?Q_format@@YAPADPADZZ) referenced in function "void __cdecl Dump(class string_t)" (?Dump@@YAXVstring_t@@@Z)
filesystem.obj : error LNK2019: unresolved external symbol "public: class string_t & __thiscall string_t::operator+(class string_t const &)" (??Hstring_t@@QAEAAV0@ABV0@@Z) referenced in function "public: void __thiscall CFileSystem::OpenFile(int *,class string_t,class string_t)" (?OpenFile@CFileSystem@@QAEXPAHVstring_t@@1@Z)
filesystem.obj : error LNK2019: unresolved external symbol "public: class string_t & __thiscall string_t::operator+(char *)" (??Hstring_t@@QAEAAV0@PAD@Z) referenced in function "public: void __thiscall CFileSystem::OpenFile(int *,class string_t,class string_t)" (?OpenFile@CFileSystem@@QAEXPAHVstring_t@@1@Z)
filesystem.obj : error LNK2019: unresolved external symbol "char * __cdecl Q_fileext(char *)" (?Q_fileext@@YAPADPAD@Z) referenced in function "public: class string_t __thiscall CFileSystem::Extension(class string_t)" (?Extension@CFileSystem@@QAE?AVstring_t@@V2@@Z)
loader.obj : error LNK2001: unresolved external symbol "char * __cdecl Q_fileext(char *)" (?Q_fileext@@YAPADPAD@Z)
filesystem.obj : error LNK2019: unresolved external symbol "public: __thiscall string_t::string_t(int)" (??0string_t@@QAE@H@Z) referenced in function "public: class string_t __thiscall CFileSystem::DateLastAccessed(int)" (?DateLastAccessed@CFileSystem@@QAE?AVstring_t@@H@Z)
globals.obj : error LNK2019: unresolved external symbol "public: void __thiscall string_t::copy(char *)" (?copy@string_t@@QAEXPAD@Z) referenced in function "public: void __thiscall CGlobals::SetGameDir(class string_t)" (?SetGameDir@CGlobals@@QAEXVstring_t@@@Z)
mempool.obj : error LNK2019: unresolved external symbol "void __cdecl Q_memset(void *,int,int)" (?Q_memset@@YAXPAXHH@Z) referenced in function "public: void __thiscall CMemPool::Init(int)" (?Init@CMemPool@@QAEXH@Z)
objloader.obj : error LNK2019: unresolved external symbol "public: char & __thiscall string_t::operator[](int)" (??Astring_t@@QAEAADH@Z) referenced in function "private: class Vector __thiscall COBJModelLoader::ReadVert(class string_t)" (?ReadVert@COBJModelLoader@@AAE?AVVector@@Vstring_t@@@Z)
objloader.obj : error LNK2019: unresolved external symbol "public: static class string_t __cdecl string_t::token(void)" (?token@string_t@@SA?AV1@XZ) referenced in function "private: class Vector __thiscall COBJModelLoader::ReadVert(class string_t)" (?ReadVert@COBJModelLoader@@AAE?AVVector@@Vstring_t@@@Z)
objloader.obj : error LNK2019: unresolved external symbol "public: static class string_t __cdecl string_t::parse(class string_t)" (?parse@string_t@@SA?AV1@V1@@Z) referenced in function "private: class Vector __thiscall COBJModelLoader::ReadVert(class string_t)" (?ReadVert@COBJModelLoader@@AAE?AVVector@@Vstring_t@@@Z)
Debug\Game.exe : fatal error LNK1120: 22 unresolved externals

This is the header file where these are coming from:

#ifndef STRTOOLS_H
# define STRTOOLS_H
#ifdef _WIN32
# pragma once
#endif

#include "types.h"

void Q_memset(void *_Dest, int _Fill, int _Count);
void Q_memcpy(void *_Dest, void *src, int _Count);
int Q_memcmp(void *_Mem1, void *_Mem2, int _Count);
void Q_strcpy(char *_Dest, char *_Src);
void Q_strncpy(char *_Dest, char *_Src, int _Count);
int Q_strlen(char *_Str);
char *Q_strrchr(char *_Str, char _C);
void Q_strcat(char *_Dest, char *_Src);
int Q_strcmp(char *_Str1, char *_Str2);
int Q_strncmp(char *_Str1, char *_Str2, int _Count);
int Q_strcasecmp(char *_Str1, char *_Str2);
int Q_strncasecmp(char *_Str1, char *_Str2, int _N);
int	Q_atoi(char *_Str);
float Q_atof(char *_Str);									
char *Q_format(char *_Format, ...);
char *Q_fileext(char *_Filename);

class string_t{
	char *_String;
	int _Allocated; // includes null char
	int _Used; // includes null char
public:
	string_t(void);
	string_t(char *_Value);
	string_t(const char *_Value);
	string_t(char *_Value, int _Size);
	string_t(int _Value);
	string_t(float _Value);
	string_t(const string_t &_Other);
	~string_t(void);

	string_t &operator=(char *_Value);
	string_t &operator=(int _Value);
	string_t &operator=(float _Value);
	string_t &operator=(const string_t &_Other);

	string_t &operator+(char *_Value);
	string_t &operator+(int _Value);
	string_t &operator+(float _Value);
	string_t &operator+(const string_t &_Other);

	string_t &operator+=(char *_Value);
	string_t &operator+=(int _Value);
	string_t &operator+=(float _Value);
	string_t &operator+=(const string_t &_Other);

	bool operator==(const char *_Other);
	bool operator==(const string_t &_Other);

	char &operator[](int _Index);

	void init(char *_Value, int _Size);
	void destroy(void);

	void copy(char *_Value);
	void append(char *_Value);

	char *base(void) const;
	int allocated(void) const;
	int size(void) const;

	static string_t parse(string_t _Data);
	static string_t token(void);
};

#endif //STRTOOLS_H

What compiler are you using? If you don't have the *.lib then you have to call LoadLibrary() and GetProcAddress() for each of the functions. But before you make any drastic changes to your code check the DLL project to see why the compiler didn't create the *.lib. It might because you didn't export any of the symbols from the DLL. google for __dllspec(__dllexport ) for examples how to do that.

I'm using whatever compiler VC++ 2008 uses. I don't have any global functions, just some classes and some template classes. I tried exporting something and that makes it create the .lib file, and I am able to link to it, but I am still getting this linker errors.

You can't just put the class in the dll without the implementing code to go along with it. Also templates can't be in a DLL and expected to be used in the application program -- it won't work because the compiler doesn't know the data type until the application program that uses it is compiled. Put templates only in header files.

I've got the implementations of the classes in .cpp files and the implementations of the templates in the header files.

I only have one file that hasn't got all it's stuff inside a header file, so mabey that could be the cause, all the templates work. Is there anything I have to do with the .dll or the .lib to make it link properly or something?

Just make sure that all the functions in the DLL implementation code are exported. You can export entire c++ classes without exporting each individual method of the class.

Thankyou, I didn't know that you had to export classes too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.