question

DangDKhanh-2637 avatar image
0 Votes"
DangDKhanh-2637 asked Viorel-1 edited

How to build library function?

Hi,
I want to build a small reusable library.
I have 2 projects, project A to build a library function (must dynamic library), and project B to run tests on it.
My problem encountered the following error:
In project B I used the following code:

 #include "StdAfx.h"
 #include "C:\......\projectA\Ent extension.h" (same folder with "Ent extension.cpp")

 void Call_plot()
 {
      ...=fent_select(..);
 }

however when I build the project I always get an error
Error LNK2019 unresolved external symbol "class Ent __cdecl fent_select(wchar_t const ,enum AcDb::OpenMode)" (?fent_select@@YAPEAVAcDbEntity@@PEB_WW4OpenMode@AcDb@@@Z) referenced in function "void __cdecl" Call_plot (?Call_plot@@YAXXZ)
How i can fix this problem?

Thanks you!




c++
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


In case of simple library, I think you can add #include "C:......\projectA\Ent extension.cpp" or add this .cpp file to Project B in Solution Explorer.

If it is simple, you can distribute the .cpp and .h files, because the DLL will only work for specific configuration, such as 32-bit, for example.


0 Votes 0 ·

1 Answer

SimpleSamples avatar image
1 Vote"
SimpleSamples answered DangDKhanh-2637 commented

See Walkthrough: Create and use your own Dynamic Link Library (C++). If I understand your question then that will help very much. Especially if you are unfamiliar with something called name mangling and how extern "C" solves that problem. You do not say if you are using __declspec; if not then the walkthrough will explain that, it is also critical. The walkthrough will also show you how to set up the testing project.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.