O/H Georgios Petasis έγραψε:
O/H Georgios Petasis έγραψε:
Hi all,

I have some C code that embeds perl into a C application.

If I compile my code with:

cl.exe <result of "perl -MExtUtils::Embed -e ccopts">

and then:

link <result of "perl -MExtUtils::Embed -e ldopts">

the resulting dll works. But if I compile it with cmake, my code always crashes, because a perl structure (a global pointer) is left uninitialised, and is always NULL. It seems that cmake inserts something that changes the building process. How can I find what commands are executed when the code is compiled/linked?
I even tried the following:

EXECUTE_PROCESS ( COMMAND ${PERL_EXECUTABLE}
-MExtUtils::Embed -e ccopts
OUTPUT_VARIABLE PERL_OUTPUT
RESULT_VARIABLE PERL_RETURN_VALUE )
IF ( NOT PERL_RETURN_VALUE )
STRING ( REPLACE "-O1" "" ADDITIONAL_PERL_CCOPTS ${PERL_OUTPUT} )
ENDIF ( NOT PERL_RETURN_VALUE )
EXECUTE_PROCESS ( COMMAND ${PERL_EXECUTABLE}
-MExtUtils::Embed -e ldopts
OUTPUT_VARIABLE PERL_OUTPUT
RESULT_VARIABLE PERL_RETURN_VALUE )
IF ( NOT PERL_RETURN_VALUE )
SET ( ADDITIONAL_PERL_LDOPTS ${PERL_OUTPUT} )
ENDIF ( NOT PERL_RETURN_VALUE )
SET ( CMAKE_C_FLAGS "-DUSE_TCL_STUBS ${ADDITIONAL_PERL_CCOPTS}" )
SET ( CMAKE_C_FLAGS_RELEASE "" )
SET ( CMAKE_C_FLAGS_DEBUG "" )
SET ( CMAKE_SHARED_LINKER_FLAGS ${ADDITIONAL_PERL_LDOPTS} )
SET ( CMAKE_SHARED_LINKER_FLAGS_RELEASE "" )
SET ( CMAKE_SHARED_LINKER_FLAGS_DEBUG "" )

But it didn't change anything. The produced dll still crashes. Any ideas?

Regards,

George
Actually, looking at the two dlls (one produced with a nmake makefile I have written, and the one built with cmake), they import different functions:

nmake cmake
300 Perl_get_context 300 Perl_get_context
265 Perl_Tstack_sp_ptr 265 Perl_Tstack_sp_ptr
214 Perl_Tmarkstack_ptr_ptr 214 Perl_Tmarkstack_ptr_ptr
263 Perl_Tstack_base_ptr 263 Perl_Tstack_base_ptr
2C5 Perl_croak 2C5 Perl_croak
2C6 Perl_croak_nocontext 2C6 Perl_croak_nocontext
196 Perl_Isv_undef_ptr 196 Perl_Isv_undef_ptr
3D6 Perl_newSVpv 3D6 Perl_newSVpv
467 Perl_sv_2mortal 467 Perl_sv_2mortal
518 Perl_win32_init 518 Perl_win32_init
51F perl_alloc 51F perl_alloc
525 perl_construct 525 perl_construct
529 perl_parse 529 perl_parse
52A perl_run 52A perl_run
526 perl_destruct 526 perl_destruct
527 perl_free 527 perl_free
454 Perl_set_context 454 Perl_set_context
2F3 Perl_eval_pv 2F3 Perl_eval_pv
462 Perl_sv_2bool 462 Perl_sv_2bool
46A Perl_sv_2pv_flags 46A Perl_sv_2pv_flags
51C boot_DynaLoader 51C boot_DynaLoader
3E1 Perl_newXS 3E1 Perl_newXS
3E2 Perl_newXS_flags
197 Perl_Isv_yes_ptr

How is possible to use the same definitions & link flags and get different results?

George

And here are the exact commands: the top line is my nmake commands, and the second line is the cmake command:

"C:\Program Files (x86)\Perl/bin/perl.exe" "C:\Program Files (x86)\Perl\lib\ExtUtils/xsubpp" -typemap "C:\Program Files (x86)\Perl\lib\ExtUtils\typemap" .\Tcl.xs > .\Tcl.c

cd C:\Users\petasis\Ellogon\lib\tclperl-3.2
"C:\Program Files (x86)\Perl\bin\perl.exe" "C:/Program Files (x86)/Perl/lib/ExtUtils/xsubpp" -typemap "C:/Program Files (x86)/Perl/lib/ExtUtils/typemap" Tcl.xs > Tcl.c


cl -nologo -c -W3 -EHsc -FD -FpBuildTemp -Gs -D "WIN32" -D "NDEBUG" -D "_WINDOWS" -D "_MBCS" -D "_USRDLL" -D "USE_TCL_STUBS" -nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -I"C:\Program Files (x86)\Perl\lib\CORE" -I"C:\Program Files (x86)\Tcl\include" -I"." .\tclperl.c .\tclthread.c .\Tcl.c

C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe @C:\Users\George\AppData\Local\Temp\nm41D2.tmp
tclperl.c

Any idea on how can I get the contents of "C:\Users\George\AppData\Local\Temp\nm41D2.tmp"? It is created and deleted so fast, that it is impossible to see it...

George
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to