Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
Hi, On Thu, 16 Mar 2017, LacaK wrote: > Then I get another error: >test_IPP.lpr(24,1) Error: Illegal COFF Magic while reading > .\Intel_IPP\ippcoremt.lib > > Am I doing something wrong, or there is some kind of incompatibility > between format of supplied libraries and object files supported by FPC ? > (I am on FPC 2.6.4 , is there chance when I will use 3.0.2 that > something changes in this?) Someone wrote already, that the internal linker doesn't support static libraries. You have to use -Xe (GNU LD, as external linker) to have a fighting chance for this to work. It's bundled with FPC. Again, I'm not saying it will work with GNU LD, I'm saying it won't work with the internal linker, and that's true for any FPC version currently. Charlie ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
ippcore.lib is just an import library for ippcore.dll. You should not use it for static linking. According to the Intel's site you should use the following libs for static linking: ippimt.lib ippsmt.lib ippcorelmt.lib Thank you! Now I do: {$linklib ippcoremt.lib} function ippGetLibVersion: PIppLibraryVersion; extdecl; external name '_ippGetLibVersion'; But I get error: ipp.pas(467,0) Error: Invalid DLL .\Intel_IPP\ippcoremt.lib, Dos Header invalid objdump for "ippcoremt.lib" shows that format is: pe-i386 When I try another: {$link .\Intel_IPP\ippcoremt.lib} function ippGetLibVersion: PIppLibraryVersion; extdecl; external name '_ippGetLibVersion'; Then I get another error: test_IPP.lpr(24,1) Error: Illegal COFF Magic while reading .\Intel_IPP\ippcoremt.lib Am I doing something wrong, or there is some kind of incompatibility between format of supplied libraries and object files supported by FPC ? (I am on FPC 2.6.4 , is there chance when I will use 3.0.2 that something changes in this?) -Laco. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
Besides that it does not work for me, when I add another two functions. Attached my example. I get error: .\Intel_IPP\\ippcoremt.lib(C:/commander/production/ipp201702gold/windows_ia32/.build/windows/obj/ia32/core/s/st/owncpufeatures.obj):(.text[_ownGetMaskFeatures]+0x35): undefined reference to `__security_cookie' Looks like you need to include the bufferoverflow.lib See here: http://stackoverflow.com/questions/21627607/gcc-linker-error-undefined-reference-to-security-cookie I do not have such library. Intel does not distribute it, there are hints that it was part of old Microsoft SDK v5 ... It becomes more complicated than I expected, so I abandon this way. I will use dynamic linking ... Thank you for your help -Laco. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
Then I get: test_IPP.lpr(17,1) Error: undefined reference to `ippGetLibVersion' (I have tried also: _ippGetLibVersion, _ippGetLibVersion@0 ...) I've downloaded the IPP libs and did some tests to make sure that static linking is possible. Thank you very much for your effort! You use cdecl, but in header files is stated stdcall for Windows, isn't it problem ? Besides that it does not work for me, when I add another two functions. Attached my example. I get error: .\Intel_IPP\\ippcoremt.lib(C:/commander/production/ipp201702gold/windows_ia32/.build/windows/obj/ia32/core/s/st/owncpufeatures.obj):(.text[_ownGetMaskFeatures]+0x35): undefined reference to `__security_cookie' L. (* // Copyright 1999-2017 Intel Corporation All Rights Reserved. // // The source code, information and material ("Material") contained herein is // owned by Intel Corporation or its suppliers or licensors, and title // to such Material remains with Intel Corporation or its suppliers or // licensors. The Material contains proprietary information of Intel // or its suppliers and licensors. The Material is protected by worldwide // copyright laws and treaty provisions. No part of the Material may be used, // copied, reproduced, modified, published, uploaded, posted, transmitted, // distributed or disclosed in any way without Intel's prior express written // permission. No license under any patent, copyright or other intellectual // property rights in the Material is granted to or conferred upon you, // either expressly, by implication, inducement, estoppel or otherwise. // Any license under such intellectual property rights must be express and // approved by Intel in writing. // // Unless otherwise agreed by Intel in writing, // you may not remove or alter this notice or any other notice embedded in // Materials by Intel or Intel's suppliers or licensors in any way. // *) // // Intel(R) Integrated Performance Primitives (Intel(R) IPP) // // Dependencies: // Image Processing: Core (ippcore), Vector Math (ippvm), Signal Processing (ipps) // // DLLs:32 64 bit // w7, myOptimized for processors with Intel SSE2 // s8, n8Optimized for processors with Supplemental Streaming SIMD Extensions 3 (SSSE3) //, m7Optimized for processors with Intel SSE3 // p8, y8Optimized for processors with Intel SSE4.2 // g9, e9Optimized for processors with Intel® Advanced Vector Extensions (Intel® AVX) and Intel® Advanced Encryption Standard New Instructions (Intel® AES-NI) // h9, l9Optimized for processors with Intel® Advanced Vector Extensions 2 (Intel® AVX2) // unit ipp; {$mode objfpc} {$macro on} {$inline on} {$align 4} {$packenum 4} {$packrecords C} interface { $DEFINE extdecl:=stdcall} {$DEFINE extdecl:=cdecl} {$link ippcoremt.lib} {$link ippvmmt.lib} {$link ippsmt.lib} {$link ippimt.lib} // // Basic Types and Macro Definitions // type int = integer; Ipp8u = byte; Ipp16u = word; Ipp32u = dword; Ipp8s = shortint; Ipp16s = smallint; Ipp32s = integer; Ipp32f = single; Ipp64s = Int64; Ipp64u = UInt64; Ipp64f = double; Ipp16f = Ipp16s; PIpp8u = ^Ipp8u; IppLibraryVersion = record major: integer; { e.g. 1 } minor: integer; { e.g. 2 } majorBuild: integer; { e.g. 3 } build: integer; { e.g. 10, always >= majorBuild} targetCpu: array [0..4-1] of AnsiChar; { corresponding to Intel(R) processor } Name: PAnsiChar; { e.g. "ippsw7"} Version: PAnsiChar; { e.g. "v1.2 Beta" } BuildDate: PAnsiChar; { e.g. "Jul 20 99" } end; PIppLibraryVersion = ^IppLibraryVersion; // // Derivative Types and Macro Definitions // (* / //The following enumerator defines a status of Intel(R) IPP operations // negative value means error *) IppStatus = ( (* errors *) ippStsNotSupportedModeErr= -,(* The requested mode is currently not supported. *) ippStsCpuNotSupportedErr = -9998,(* The target CPU is not supported. *) ippStsInplaceModeNotSupportedErr = -9997,(* The inplace operation is currently not supported. *) ippStsABIErrXMM15= -8017, (* XMM15 is not saved by Intel(R) IPP function *) ippStsABIErrXMM14= -8016, (* XMM14 is not saved by Intel(R) IPP function *) ippStsABIErrXMM13= -8015, (* XMM13 is not saved by Intel(R) IPP function *) ippStsABIErrXMM12= -8014, (* XMM12 is not saved by Intel(R) IPP function *) ippStsABIErrXMM11= -8013, (* XMM11 is not
Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
On 3/16/2017 1:12 PM, LacaK wrote: Then I get: test_IPP.lpr(17,1) Error: undefined reference to `ippGetLibVersion' (I have tried also: _ippGetLibVersion, _ippGetLibVersion@0 ...) I've downloaded the IPP libs and did some tests to make sure that static linking is possible. Thank you very much for your effort! You use cdecl, but in header files is stated stdcall for Windows, isn't it problem ? You are right. The headers use stdcall. You need also use stdcall and add "_" before names - use the same names as reported by objdump. function ippGetLibVersion: PIppLibraryVersion; stdcall; external name '_ippGetLibVersion@0'; Besides that it does not work for me, when I add another two functions. Attached my example. I get error: .\Intel_IPP\\ippcoremt.lib(C:/commander/production/ipp201702gold/windows_ia32/.build/windows/obj/ia32/core/s/st/owncpufeatures.obj):(.text[_ownGetMaskFeatures]+0x35): undefined reference to `__security_cookie' Looks like you need to include the bufferoverflow.lib See here: http://stackoverflow.com/questions/21627607/gcc-linker-error-undefined-reference-to-security-cookie Yury. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
Dňa 16.3.2017 o 10:03 Karoly Balogh (Charlie/SGR) napísal(a): Hi, On Thu, 16 Mar 2017, LacaK wrote: Then I get another error: test_IPP.lpr(24,1) Error: Illegal COFF Magic while reading .\Intel_IPP\ippcoremt.lib Am I doing something wrong, or there is some kind of incompatibility between format of supplied libraries and object files supported by FPC ? (I am on FPC 2.6.4 , is there chance when I will use 3.0.2 that something changes in this?) Someone wrote already, that the internal linker doesn't support static libraries. You have to use -Xe (GNU LD, as external linker) to have a fighting chance for this to work. It's bundled with FPC. Again, I'm not saying it will work with GNU LD, I'm saying it won't work with the internal linker, and that's true for any FPC version currently. Thank you. Now I have this FPC command line (added -Xe): D:\Programy\Lazarus\fpc\2.6.4\bin\i386-win32\fpc.exe -B -MObjFPC -Scghi -O1 -g -gl -XX -l -vewnhibq -FiD:\TEMP\zmazma\lib\i386-win32 -FlD:\TEMP\zmazma\Intel_IPP -FuD:\TEMP\zmazma\ -FUD:\TEMP\zmazma\lib\i386-win32\ -Xe test_IPP.lpr But I still get : Error: Invalid DLL .\Intel_IPP\ippcoremt.lib, Dos Header invalid When I have removed from source code {$linklib} and use this command line: (added: -k--library -k:ippcoremt.lib -k--library-path -kD:\TEMP\zmazma\Intel_IPP) D:\Programy\Lazarus\fpc\2.6.4\bin\i386-win32\fpc.exe -B -MObjFPC -Scghi -O1 -g -gl -k--library -k:ippcoremt.lib -k--library-path -kD:\TEMP\zmazma\Intel_IPP -vewnhibq -FiD:\TEMP\zmazma\lib\i386-win32 -FlD:\TEMP\zmazma\Intel_IPP -FuD:\TEMP\zmazma\ -FUD:\TEMP\zmazma\lib\i386-win32\ -Xe test_IPP.lpr Then I get: test_IPP.lpr(17,1) Error: undefined reference to `ippGetLibVersion' (I have tried also: _ippGetLibVersion, _ippGetLibVersion@0 ...) -Laco ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows
On 3/16/2017 12:01 PM, LacaK wrote: Then I get: test_IPP.lpr(17,1) Error: undefined reference to `ippGetLibVersion' (I have tried also: _ippGetLibVersion, _ippGetLibVersion@0 ...) I've downloaded the IPP libs and did some tests to make sure that static linking is possible. The working declaration is: {$L ippcoremt.lib} function ippGetLibVersion: PIppLibraryVersion; cdecl; external name 'ippGetLibVersion@0'; You need to use the external linker via the -Xe option, since internal linker does not support static libraries. Only single object files can be linked. ippGetLibVersion@0 - is the C++ mangled name used by MS VC++. FPC supports then "cppdecl" calling convention, but only for the GCC compiler, which uses different name mangling algorithm. So you need to use cdecl and manually specify the name. Function names can be found using "objdump -t ippcoremt.lib". You should specify the name without the "_" prefix. It is added automatically when cdecl is used. Yury. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel