|
From: yazan w. <ya...@ya...> - 2007-06-13 17:28:46
|
Hello everyone,
I'm new to DLL coding, so this may be simple problem,
I've written few C++ functions with MinGW, and I've tried to make a .dll and .lib of them to use it with msvc, i built it as a shared library, using the following commands
g++ -c -DBUILD_DLL testdll.cpp
g++ -shared -o testdll.dll testdll.o -Wl,--output-def,testdll.def,--out-implib,libtestdll.a
//CREATE A LIB FOR MSVC
lib /machine:i386 /def:testdll.def
//COMPILE IT USING COMMAND LINE
CL MAIN.CPP TESTDLL.LIB
to here, everything works fine, and I have a main.exe, but the problem is when I'm trying to run main.exe, I get run-time error, and sometimes I don't get run time errors, but it also does not work write,
this is sample of my .h file
////####################################
#ifndef _DLL_H_
#define _DLL_H_
#include<vector>
#include<string>
using std::vector;
using std::string;
#ifdef __cplusplus
extern "C" {
#endif
#if BUILDING_DLL
# define EXPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define EXPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
//some global vraiables,
//define error vlaues
#define SUCCESS_ 0 // 0 = success
#define EACCESS_ -1 //-1 = access denied
#ifdef _WIN32
const char sep = '\\';
#else
const char sep = '/';
#endif
struct error_filename
{
string filename;
int errorcode;
};
EXPORT extern bool same_device;
int __stdcall EXPORT copy_file(const char* src, const char* dst);
int __stdcall EXPORT move_dir_ignore_errors(const char* src, const char*dst, vector<error_filename>& filenames);
....
////####################################
There is a standard C++ code in the implementation file ( .cpp ), and I can also provide it if anyone is interested,
does there is any problem declaring the struct that way, or is it ok, if anyone has any suggestion, I would be happy to hear them
Thankx very much,
____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz |