create 2 project, put those defination in project/setting.

scorpio (scorpio)
本文发表在 rolia.net/zh 相约加拿大网上社区枫下论坛
//cod.h
#ifndef cod_h
#define cod_h
class cod{
public:
cod();
~cod();
void read_file();
#ifdef _DEC_LIB_
void dec();
#endif
#ifdef _ENC_LIB_
void enc();
#endif
};
#endif

//cod.cpp
#include "stdio.h"
#include "cod.h"

cod::cod()
{
}
cod::~cod()
{
}
void cod::read_file()
{
printf("cod::read_file\n");
}
#ifdef _DEC_LIB_
void cod::dec()
{
printf("cod::dec\n");
}
#endif
#ifdef _ENC_LIB_
void cod::enc()
{
printf("cod::enc\n");
}
#endif

//enc.h
#ifndef enc_h
#define enc_h
class enc{
void *penc;
public:
enc();
~enc();
void encode();
};
#endif

//dec.h
#ifndef dec_h
#define dec_h
class dec{
void *pdec;
public:
dec();
~dec();
void decode();
};
#endif

//codec.cpp
#include "codec.h"
#include "cod.h"

#ifdef _DEC_LIB_
dec::dec()
{
pdec = new cod;
((cod *)pdec)->read_file();
}
dec::~dec()
{
delete pdec;
}
void dec::decode()
{
((cod *)pdec)->dec();
}
#endif
#ifdef _ENC_LIB_
enc::enc()
{
penc = new cod;
((cod *)penc)->read_file();
}
enc::~enc()
{
delete penc;
}
void enc::encode()
{
((cod *)penc)->enc();
}
#endif

//test.cpp
#include "enc.h"
#include "dec.h"
#pragma comment(lib, "enc.lib")
#pragma comment(lib, "dec.lib")
void main(){
enc e;
e.encode();
dec d;
d.decode();
}
更多精彩文章及讨论,请光临枫下论坛. 网址: rolia.net/zh
(#89043@0)
2001-6-3 -05:00

回到话题: help help! 怎么在一个EXE里连两个STATIC LIBRARY?这两个LIB SHARE一些FUNCTION,我联的时候VC报错:a.lib: function xyz is already defined in b.lib.

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=89043