F
Fleµve
Guest
Hello,
I've made a DirectX application and I will made a Static Library with. Instead create a new project, I've apply some modification to my actual project. I Begin to create new configuration (called Static Library) based on Release. I've also change (Application .exe) to (Static Library .lib) inside this configuration and adding _LIB define. To exclude main from library, the new main look like this :
#include "stdafx.h"
#define DESKTOP_AMDVIDEO 1
#define ALLOC_CONSOLE 0
#include <RXCoreDesktop.h>
#ifndef _LIB //Exclude From Library
#include "Document.h"
#include "TestInterface.h"
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
LPWSTR *argv;
int argc;
argv = CommandLineToArgvW(GetCommandLine(), &argc);
#if ALLOC_CONSOLE == 1
if (AllocConsole())
...
Now I build this Library without any error or warning. Then I decide to test inside a new solution. unfortunately I got some LNK2001 (unresolved external symbol). I fix it by adding some Include and class specialization inside top root include of my framework (RXCoreDesktop.h).
#ifdef _LIB
#include <RXButton.h>
#include <RXEdit.h>
#include <RXLivreReserv.h>
#include <RXMedia.h>
#include <RXMeshes.h>
#include <RXRS232.h>
#include <RXStrList.h>
#include <RXText.h>
template class CRCArray<CRXInterface*>; //Class Specialization
template class CRCArray<CRXComponent*>;
#endif
Now after rebuilding the library, everything was fine. I can program my framework with the LIB version.
#pragma comment(lib, "ScragDesktop.lib")
I can add component, interface, modify code like the source (CPP) version. But,all my dynamic structure are Template. That mean now, I can only use dynamic structure that define inside class specialization and its sub-level.
CRDArray<unsigned short> a; //OK
CRDArray<float> h; //OK
CRCArray<CRXInterface*> g; //OK
CRCArray<CRXComponent*> g2; //OK
CRQueue<MessageMap> Map; //OK
CRDArray<char> k; //NO LNK2001
CRDArray<int> kh; //NO LNK2001
CRCArray<NewClass*> gg; //NO LNK2001
I got LNK2001 : (unresolved external symbol)
If a re-add RDDynStruct.h, I got LNK2005 : (already defined)
if I use /Force:Multiple, I got LNK4006.
The only way, that I found is : Made 2 copy of RDDynStruct.h, One for the core (RDDynCore.h) and the other for the user (RDDynStruct.h). Also change class name for Core. Like:
USER -> CORE
CRCArray -> CRCCoreArray
CRDArray -> CRDCoreArray
CRTree -> CRCoreTree
CRQueue -> CRCoreQueue
Have you better idea?
Thanks.
Continue reading...
I've made a DirectX application and I will made a Static Library with. Instead create a new project, I've apply some modification to my actual project. I Begin to create new configuration (called Static Library) based on Release. I've also change (Application .exe) to (Static Library .lib) inside this configuration and adding _LIB define. To exclude main from library, the new main look like this :
#include "stdafx.h"
#define DESKTOP_AMDVIDEO 1
#define ALLOC_CONSOLE 0
#include <RXCoreDesktop.h>
#ifndef _LIB //Exclude From Library
#include "Document.h"
#include "TestInterface.h"
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
LPWSTR *argv;
int argc;
argv = CommandLineToArgvW(GetCommandLine(), &argc);
#if ALLOC_CONSOLE == 1
if (AllocConsole())
...
Now I build this Library without any error or warning. Then I decide to test inside a new solution. unfortunately I got some LNK2001 (unresolved external symbol). I fix it by adding some Include and class specialization inside top root include of my framework (RXCoreDesktop.h).
#ifdef _LIB
#include <RXButton.h>
#include <RXEdit.h>
#include <RXLivreReserv.h>
#include <RXMedia.h>
#include <RXMeshes.h>
#include <RXRS232.h>
#include <RXStrList.h>
#include <RXText.h>
template class CRCArray<CRXInterface*>; //Class Specialization
template class CRCArray<CRXComponent*>;
#endif
Now after rebuilding the library, everything was fine. I can program my framework with the LIB version.
#pragma comment(lib, "ScragDesktop.lib")
I can add component, interface, modify code like the source (CPP) version. But,all my dynamic structure are Template. That mean now, I can only use dynamic structure that define inside class specialization and its sub-level.
CRDArray<unsigned short> a; //OK
CRDArray<float> h; //OK
CRCArray<CRXInterface*> g; //OK
CRCArray<CRXComponent*> g2; //OK
CRQueue<MessageMap> Map; //OK
CRDArray<char> k; //NO LNK2001
CRDArray<int> kh; //NO LNK2001
CRCArray<NewClass*> gg; //NO LNK2001
I got LNK2001 : (unresolved external symbol)
If a re-add RDDynStruct.h, I got LNK2005 : (already defined)
if I use /Force:Multiple, I got LNK4006.
The only way, that I found is : Made 2 copy of RDDynStruct.h, One for the core (RDDynCore.h) and the other for the user (RDDynStruct.h). Also change class name for Core. Like:
USER -> CORE
CRCArray -> CRCCoreArray
CRDArray -> CRDCoreArray
CRTree -> CRCoreTree
CRQueue -> CRCoreQueue
Have you better idea?
Thanks.
Continue reading...