Hello all,
I'm newbie with LCC / LCC64.
Just a little test (construct very simple DLL and test these) with CB and these two compilers C.
First source : Essai_DLL
#include <stdio.h>
#include "hello.h"
#pragma hdrstop
#if defined(_WIN32)||defined(_WIN64)
#ifdef BUILD_DLL
#define DLLENTRY __declspec( dllexport )
#else
#define DLLENTRY __declspec( dllimport )
#endif
DLLENTRY int CALLINGCONV hello( void )
{
printf( "========> Hello from a DLL!\n" );
return( 0 );
}
/* Optional LibMain function */
BOOL APIENTRY DllMain( HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved ) {
switch( dwReason ) {
case DLL_PROCESS_ATTACH:
printf( "DLL attaching to process.\n" );
break;
case DLL_PROCESS_DETACH:
printf( "DLL detaching from process.\n" );
break;
case DLL_THREAD_ATTACH:
printf( "DLL attaching to thread.\n" );
break;
case DLL_THREAD_DETACH:
printf( "DLL detaching from thread.\n" );
break;
}
return( 1 ); /* Indicate success */
}
#endif // defined(_WIN32)||defined(_WIN64)
#ifdef __OS2__
#include <os2.h>
BOOL APIENTRY LibMain( HMODULE hmodDLL, ULONG ulTermination )
{
if( ulTermination ) {
printf( "DLL is terminating.\n" );
} else {
printf( "DLL is initializing.\n" );
}
return( 1 ); /* Indicate success */
}
#endif // defined(__OS2__)
Source of hello.h
#ifndef HEADER_8520596113737659
#define HEADER_8520596113737659
#if defined(_WIN32)||defined(_WIN64)
#include <windows.h>
#ifdef BUILD_DLL
#define DLLENTRY __declspec( dllexport )
#else
#define DLLENTRY __declspec( dllimport )
#endif
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN
#endif
/**** Spécifique Borland C++ */
#if defined __BORLANDC__
#define CALLINGCONV __stdcall
#else
#define CALLINGCONV
#endif
DLLENTRY int CALLINGCONV hello( void );
#endif //defined(_WIN32)||defined(_WIN64)
#endif // header guard
Last source : main.c (console application)
#if defined __CYGWIN__ || defined __LCC__
#define WIN32_LEAN_AND_MEAN
#endif
#include <stdio.h>
#include "hello.h"
int main( void )
{
printf( "Entered main, calling DLL.\n" );
hello();
printf( "Back in main, exiting.\n" );
return( 0 );
}
Four génerations of DLL : "Debug LCC32" "Release LCC32" "Debug LCC64" "Release LCC64" ->
-------------- Build: Debug lcc in Essai_DLL (compiler: LCC Compiler)---------------
lcc.exe -c -IC:\lcc\include -IC:\lcc\include -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN32 hello.c -Foobjlcc32\Debug\hello.obj
lcclnk.exe -dll -LC:\lcc\lib -LC:\lcc\lib -dll objlcc32\Debug\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc32\Debug\libEssai_DLL.dll
Output file is binlcc32\Debug\libEssai_DLL.dll with size 99.00 KB
Running target post-build steps
pedump /EXP objlcc32\Debug\hello.obj
OBJLCC32\DEBUG\HELLO.OBJ
_hello
_DllMain@12
Process terminated with status 0 (0 minute(s), 6 second(s))
0 error(s), 0 warning(s) (0 minute(s), 6 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
-------------- Build: Release lcc in Essai_DLL (compiler: LCC Compiler)---------------
lcc.exe -c -IC:\lcc\include -IC:\lcc\include -DNDEBUG -DBUILD_DLL -D_WIN32 hello.c -Foobjlcc32\Release\hello.obj
lcclnk.exe -dll -LC:\lcc\lib -LC:\lcc\lib -dll objlcc32\Release\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc32\Release\libEssai_DLL.dll
Output file is binlcc32\Release\libEssai_DLL.dll with size 98.00 KB
Running target post-build steps
pedump /EXP objlcc32\Release\hello.obj
OBJLCC32\RELEASE\HELLO.OBJ
_hello
_DllMain@12
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
-------------- Build: Debug lcc64 in Essai_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN64 hello.c -Foobjlcc64\Debug\hello.obj
lcclnk64.exe -dll -LC:\lcc64\lib64 -dll objlcc64\Debug\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc64\Debug\libEssai_DLL.dll
Output file is binlcc64\Debug\libEssai_DLL.dll with size 169.81 KB
Running target post-build steps
pedump /EXP objlcc64\Debug\hello.obj
OBJLCC64\DEBUG\HELLO.OBJ
hello
DllMain
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
-------------- Build: Debug lcc64 in Essai_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN64 hello.c -Foobjlcc64\Debug\hello.obj
lcclnk64.exe -dll -LC:\lcc64\lib64 -dll objlcc64\Debug\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc64\Debug\libEssai_DLL.dll
Output file is binlcc64\Debug\libEssai_DLL.dll with size 169.81 KB
Running target post-build steps
pedump /EXP objlcc64\Debug\hello.obj
OBJLCC64\DEBUG\HELLO.OBJ
hello
DllMain
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
With LCC32, console application compile and link, and tests OK.
With LCC64, console application compile, but don't link with message, for two cibles DEBUG and RELEASE :
-------------- Build: Release lcc64 in Test_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -DNDEBUG -D_WIN64 main.c -Foobjlcc64\Release\main.obj
lcclnk64.exe -subsystem console -Lbinlcc64\Release\ -LC:\lcc64\lib64 objlcc64\Release\main.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib libEssai_DLL.lib -o binlcc64\Release\Test_DLL.exe
objlcc64\release\main.obj .text: undefined reference to '__imp_hello' Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Test_DLL_build_log.html
What' wrong (same identical sources for the four construct) ?
Thank's.
Thierry DECHAIZE (very "old" newbie developper).
PS : All is OK with BORLAND C++, VISUAL STUDIO 2022 + kits M$, Mingw32/64, CYGWIN 32/64, MSYS264.
Le mardi 22 février 2022 à 17:11:02 UTC+1, Thierry Dechaize a écrit :
Hello all,
I'm newbie with LCC / LCC64.
Just a little test (construct very simple DLL and test these) with CB and these two compilers C.
First source : Essai_DLL
#include <stdio.h>
#include "hello.h"
#pragma hdrstop
#if defined(_WIN32)||defined(_WIN64)
#ifdef BUILD_DLL
#define DLLENTRY __declspec( dllexport )
#else
#define DLLENTRY __declspec( dllimport )
#endif
DLLENTRY int CALLINGCONV hello( void )
{
printf( "========> Hello from a DLL!\n" );
return( 0 );
}
/* Optional LibMain function */
BOOL APIENTRY DllMain( HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
switch( dwReason ) {
case DLL_PROCESS_ATTACH:
printf( "DLL attaching to process.\n" );
break;
case DLL_PROCESS_DETACH:
printf( "DLL detaching from process.\n" );
break;
case DLL_THREAD_ATTACH:
printf( "DLL attaching to thread.\n" );
break;
case DLL_THREAD_DETACH:
printf( "DLL detaching from thread.\n" );
break;
}
return( 1 ); /* Indicate success */
}
#endif // defined(_WIN32)||defined(_WIN64)
#ifdef __OS2__
#include <os2.h>
BOOL APIENTRY LibMain( HMODULE hmodDLL, ULONG ulTermination )
{
if( ulTermination ) {
printf( "DLL is terminating.\n" );
} else {
printf( "DLL is initializing.\n" );
}
return( 1 ); /* Indicate success */
}
#endif // defined(__OS2__)
Source of hello.h
#ifndef HEADER_8520596113737659
#define HEADER_8520596113737659
#if defined(_WIN32)||defined(_WIN64)
#include <windows.h>
#ifdef BUILD_DLL
#define DLLENTRY __declspec( dllexport )
#else
#define DLLENTRY __declspec( dllimport )
#endif
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN
#endif
/**** Spécifique Borland C++ */
#if defined __BORLANDC__
#define CALLINGCONV __stdcall
#else
#define CALLINGCONV
#endif
DLLENTRY int CALLINGCONV hello( void );
#endif //defined(_WIN32)||defined(_WIN64)
#endif // header guard
Last source : main.c (console application)
#if defined __CYGWIN__ || defined __LCC__
#define WIN32_LEAN_AND_MEAN
#endif
#include <stdio.h>
#include "hello.h"
int main( void )
{
printf( "Entered main, calling DLL.\n" );
hello();
printf( "Back in main, exiting.\n" );
return( 0 );
}
Four génerations of DLL : "Debug LCC32" "Release LCC32" "Debug LCC64" "Release LCC64" ->
-------------- Build: Debug lcc in Essai_DLL (compiler: LCC Compiler)---------------
lcc.exe -c -IC:\lcc\include -IC:\lcc\include -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN32 hello.c -Foobjlcc32\Debug\hello.obj
lcclnk.exe -dll -LC:\lcc\lib -LC:\lcc\lib -dll objlcc32\Debug\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc32\Debug\libEssai_DLL.dll
Output file is binlcc32\Debug\libEssai_DLL.dll with size 99.00 KB
Running target post-build steps
pedump /EXP objlcc32\Debug\hello.obj
OBJLCC32\DEBUG\HELLO.OBJ
_hello
_DllMain@12
Process terminated with status 0 (0 minute(s), 6 second(s))
0 error(s), 0 warning(s) (0 minute(s), 6 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
-------------- Build: Release lcc in Essai_DLL (compiler: LCC Compiler)---------------
lcc.exe -c -IC:\lcc\include -IC:\lcc\include -DNDEBUG -DBUILD_DLL -D_WIN32 hello.c -Foobjlcc32\Release\hello.obj
lcclnk.exe -dll -LC:\lcc\lib -LC:\lcc\lib -dll objlcc32\Release\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc32\Release\libEssai_DLL.dll
Output file is binlcc32\Release\libEssai_DLL.dll with size 98.00 KB Running target post-build steps
pedump /EXP objlcc32\Release\hello.obj
OBJLCC32\RELEASE\HELLO.OBJ
_hello
_DllMain@12
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
-------------- Build: Debug lcc64 in Essai_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN64 hello.c -Foobjlcc64\Debug\hello.obj
lcclnk64.exe -dll -LC:\lcc64\lib64 -dll objlcc64\Debug\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc64\Debug\libEssai_DLL.dll
Output file is binlcc64\Debug\libEssai_DLL.dll with size 169.81 KB
Running target post-build steps
pedump /EXP objlcc64\Debug\hello.obj
OBJLCC64\DEBUG\HELLO.OBJ
hello
DllMain
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
-------------- Build: Debug lcc64 in Essai_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN64 hello.c -Foobjlcc64\Debug\hello.obj
lcclnk64.exe -dll -LC:\lcc64\lib64 -dll objlcc64\Debug\hello.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib -o binlcc64\Debug\libEssai_DLL.dll
Output file is binlcc64\Debug\libEssai_DLL.dll with size 169.81 KB
Running target post-build steps
pedump /EXP objlcc64\Debug\hello.obj
OBJLCC64\DEBUG\HELLO.OBJ
hello
DllMain
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Essai_DLL_build_log.html
With LCC32, console application compile and link, and tests OK.
With LCC64, console application compile, but don't link with message, for two cibles DEBUG and RELEASE :
-------------- Build: Release lcc64 in Test_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -DNDEBUG -D_WIN64 main.c -Foobjlcc64\Release\main.obj
lcclnk64.exe -subsystem console -Lbinlcc64\Release\ -LC:\lcc64\lib64 objlcc64\Release\main.obj glu32.lib opengl32.lib advapi32.lib comdlg32.lib gdi32.lib winmm.lib libEssai_DLL.lib -o binlcc64\Release\Test_DLL.exe
objlcc64\release\main.obj .text: undefined reference to '__imp_hello' Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://C:/src/EssaiC/Test_DLL_build_log.html
What' wrong (same identical sources for the four construct) ?
Thank's.
Thierry DECHAIZE (very "old" newbie developper).
PS : All is OK with BORLAND C++, VISUAL STUDIO 2022 + kits M$, Mingw32/64, CYGWIN 32/64, MSYS264.Hello all,
Hello Jacob Navia,
Dead forum ?
I'm continued with different tests (no solution today !!!).
Changes realized :
hello.c --->
#if defined __CYGWIN__ || defined __LCC__
#define WIN32_LEAN_AND_MEAN
#endif
#include <stdio.h>
#include "hello.h"
#pragma hdrstop
#if defined(_WIN32)||defined(_WIN64)
DLLENTRY int CALLINGCONV hello( void )
{
printf( "========> Hello from a DLL!\n" );
return( 0 );
}
#if defined(__LCC__) && !defined(_WIN64)
/* LibMain needed by lcc compiler - only for 32 bits compilation */
int WINAPI LibMain(HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
printf( "DLL attaching to process.\n" );
break;
case DLL_PROCESS_DETACH:
printf( "DLL detaching from process.\n" );
break;
case DLL_THREAD_ATTACH:
printf( "DLL attaching to thread.\n" );
break;
case DLL_THREAD_DETACH:
printf( "DLL detaching from thread.\n" );
break;
}
return TRUE;
}
#else
/* Optional DllMain for many compilers C/C++ */
BOOL WINAPI DllMain( HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
switch( dwReason ) {
case DLL_PROCESS_ATTACH:
printf( "DLL attaching to process.\n" );
break;
case DLL_PROCESS_DETACH:
printf( "DLL detaching from process.\n" );
break;
case DLL_THREAD_ATTACH:
printf( "DLL attaching to thread.\n" );
break;
case DLL_THREAD_DETACH:
printf( "DLL detaching from thread.\n" );
break;
}
return( 1 ); /* Indicate success */
}
#endif // defined(__LCC__) && !defined(_WIN64)
#endif // defined(_WIN32)||defined(_WIN64)
#ifdef __OS2__
#include <os2.h>
BOOL APIENTRY LibMain( HMODULE hmodDLL, ULONG ulTermination )
{
if( ulTermination ) {
printf( "DLL is terminating.\n" );
} else {
printf( "DLL is initializing.\n" );
}
return( 1 ); /* Indicate success */
}
#endif // defined(__OS2__)
-------------- Build: Debug lcc in Essai_DLL (compiler: LCC Compiler)---------------
lcc.exe -c -IC:\lcc\include -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN32 hello.c -Foobjlcc32\Debug\hello.obj
lcclnk.exe -dll -LC:\lcc\lib objlcc32\Debug\hello.obj kernel32.lib user32.lib -o binlcc32\Debug\Essai_DLL.dll
Output file is binlcc32\Debug\Essai_DLL.dll with size 99.00 KB
Running target post-build steps
pedump /EXP binlcc32\Debug\Essai_DLL.dll
binlcc32\Debug\Essai_DLL.dll
_hello
pedump /EXP binlcc32\Debug\Essai_DLL.lib
Name of the dll unknown!
$tEssai_
$hEssai_
_hello
$tEssai_
cmd /c type binlcc32\Debug\Essai_DLL.exp
Essai_DLL.dll
_hello _hello
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
-------------- Build: Release lcc in Essai_DLL (compiler: LCC Compiler)---------------
lcc.exe -c -IC:\lcc\include -DNDEBUG -DBUILD_DLL -D_WIN32 hello.c -Foobjlcc32\Release\hello.obj
lcclnk.exe -dll -LC:\lcc\lib objlcc32\Release\hello.obj kernel32.lib user32.lib -o binlcc32\Release\Essai_DLL.dll
Output file is binlcc32\Release\Essai_DLL.dll with size 98.00 KB
Running target post-build steps
pedump /EXP binlcc32\Release\Essai_DLL.dll
binlcc32\Release\Essai_DLL.dll
_hello
pedump /EXP binlcc32\Release\Essai_DLL.lib
Name of the dll unknown!
$tEssai_
$hEssai_
_hello
$tEssai_
cmd /c type binlcc32\Release\Essai_DLL.exp
Essai_DLL.dll
_hello _hello
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
-------------- Build: Debug lcc64 in Essai_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -g2 -D_DEBUG -DDEBUG -DBUILD_DLL -D_WIN64 hello.c -Foobjlcc64\Debug\hello.obj
lcclnk64.exe -dll -LC:\lcc64\lib64 objlcc64\Debug\hello.obj kernel32.lib user32.lib -o binlcc64\Debug\Essai_DLL.dll
Output file is binlcc64\Debug\Essai_DLL.dll with size 169.81 KB
Running target post-build steps
pedump /EXP binlcc64\Debug\Essai_DLL.dll
hello
pedump /EXP binlcc64\Debug\Essai_DLL.lib
Name of the dll unknown!
hello
cmd /c type binlcc64\Debug\Essai_DLL.exp
Essai_DLL.dll
hello hello
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
-------------- Build: Release lcc64 in Essai_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -DNDEBUG -DBUILD_DLL -D_WIN64 hello.c -Foobjlcc64\Release\hello.obj
lcclnk64.exe -dll -LC:\lcc64\lib64 objlcc64\Release\hello.obj kernel32.lib user32.lib -o binlcc64\Release\Essai_DLL.dll
Output file is binlcc64\Release\Essai_DLL.dll with size 168.81 KB
Running target post-build steps
pedump /EXP binlcc64\Release\Essai_DLL.dll
hello
pedump /EXP binlcc64\Release\Essai_DLL.lib
Name of the dll unknown!
hello
cmd /c type binlcc64\Release\Essai_DLL.exp
Essai_DLL.dll
hello hello
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Result of test DLL with version 32 bits of lcc :
Test_DLL.exe (console application)
DLL attaching to process.
Entered main, calling DLL.
========> Hello from a DLL!
Back in main, exiting.
DLL detaching from process.
No way to link test DLL with 64 bits of lcc :
-------------- Build: Debug lcc64 in Test_DLL (compiler: LCC Compiler 64)---------------
lcc64.exe -c -IC:\lcc64\include64 -g2 -D_DEBUG -DDEBUG -D_WIN64 main.c -Foobjlcc64\Debug\main.obj
lcclnk64.exe -subsystem console -LC:\lcc64\lib64 -s objlcc64\Debug\main.obj binlcc64\Debug\Essai_DLL.lib kernel32.lib user32.lib -o binlcc64\Debug\Test_DLL.exe
Error c:\src\win32\test_dll\main.c 12 undefined reference to __imp_hello Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
My questions :
Why PEDUMP /EXP give differents results beetween 32 and 64 bits ?
What are these singularies exports on 32 bits lcc ($tEssai_, $hEssai_) not present on 64 bits lcc ?
I like resolved these problems ! Help me ?
Thank's for all.
Thierry D.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 213:42:51 |
Calls: | 6,619 |
Calls today: | 1 |
Files: | 12,168 |
Messages: | 5,317,430 |