Borland C++ v5.5 - LIB & DLL Command Line
2010.07.05 23:58
레조 Edit

- 첨부 파일
- Static_LIB.zip935.5KB
- Import_LIB.zip995.9KB
- Dynamic_Linking_Without_Imports.zip996.3KB
1. static LIB 만들기 [ lib 파일 생성 ] bcc32 -c hello.cpp tlib hello.lib /u hello.obj [ lib 사용 ] 라이브러리를 사용할 때 라이브러리 함수들의 선언이 있는 *.h 파일을 include 한다. bcc32 –c uselib.cpp ilink32 c0x32.obj uselib.obj, uselib.exe,, import32.lib cw32.lib hello.lib 2. LIB 사용 예제 [ Example에 사용된 파일 구성 ] - LIB – hello.h hello.cpp hello.lib - 소스 – hello.h uselib.cpp hello.lib 3. import LIB 만들기 여기서 만들어지는 dll에서 import 라이브러리를 만들어 링크할때 사용한다. lib는 dll 내의 함수 선언정보 정도만 있기 때문에 용량이 작다. dll 생성시(컴파일시)에 –tCDR을 사용할 경우 생성되는 dll은 마치 –tCR로 컴파일한 exe 처럼 공유 라이브러리를 dll과 같이 배포해 주어야한다. (기본적으로 –tCD를 기준으로 dll을 생성한다.) bcc32 –tCD hello.cpp implib hello.lib hello.dll bcc32 –c uselib.cpp ilink32 c0x32.obj uselib.obj, uselib.exe,, import32.lib cw32.lib hello.lib 4. import LIB 사용 예제 실제 배포할때는 exe 파일과 함계 dll 파일만 같이 배포해주면 된다. - DLL – hello.h hello.cpp -> hello.dll hello.dll -> hello.lib - 소스 – hello.h uselib.cpp hello.lib hello.dll 5. DLL 동적 로딩하기 동적 dll 로딩의 경우 dll에 관해 사용할 함수 정보를 알고있는 경우에 사용한다. 또한 dll 모듈이 많은 리소스를 차지하여 프로그램 시작 로딩 속도가 늦어질 경우 혹은 필요한 상황이 단발성으로 생기는 경우등 dll이 꼭 필요한 경우가 아니라면 쓰지 않아도 되는 상황에 많이 사용한다. 프로그램이 종료하면 자동으로 Free되며, 직접 FreeLibrary를 사용하여 로딩시 생성한 인스턴스를 해제할 수 있다. DLL에서 할당한 자원은 DLL이 종료될 때 반드시 해제해야 Access Violation을 피할 수 있다. DllMain과 DllEntryPoint의 관계는 아래와같다. DllMain is a placeholder for the library-defined function name. Earlier versions of the SDK documentation used DllEntryPoint as the entry-point function name. You must specify the actual name you use when you build your DLL. For more information, see the documentation included with your development tools. – MSDN - bcc32 –tCD hello.cpp bcc32 –c uselib.cpp ilink32 c0x32.obj uselib.obj, uselib.exe,, import32.lib cw32.lib 6. DLL 동적 로딩 사용 예제 dll 동적 로딩에서는 만들어진 dll만 exe 와 같이 배포하면된다. (-tCD 컴파일시) - DLL – hello.h hello.cpp hello.dll - 소스 – hello.h uselib.cpp hello.dll
Resource DLL 추가 - 2007.04.16
EXE나 DLL 등에 RES파일을 추가하려면 #pragma resource를 사용합니다.
<< DLL 생성하기 >>
- 콘솔
bcc32 -tCD ResDll.cpp
- Win32
bcc32 -tWD ResDll.cpp
Ex) ResDll.cpp
//---------------------------------------------------------------------------
#include <windows.h>
#pragma resource "LocaleKOR.res"
#pragma hdrstop
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
[출처]
http://www.codeself.com/index.php?page=1104&action=read&tupleno=5
http://turboc.borlandforum.com/impboard/impboard.dll?action=read&db=cpp_tutorial&no=8
이 글과 관련된 글
- [2010/07/06] Borland C++ v5.5 - MAKE (219)
- [2010/07/01] Borland C++ v5.5 - Resource (223)
- [2010/06/29] Borland C++ v5.5 - Compile & Link (277)
- [2010/06/14] Special Issue on C++Builder 2010 (BCBJ) (545)
- [2008/10/30] 연산자와 예약어 - C 프로그래밍은 산수다 III (0)
CODESELF 커뮤니티(