我有用於Windows Mobile 6的應用程序。要構建它,我使用cegcc(arm-mingw32ce)。 現在我有了新SDK的新設備,並且此SDK中的一些功能必須添加到此應用程序中。 這裏是SDK。cegcc:使用vC++(mangling issue)編譯失敗的鏈接導入庫
header.h
#ifndef _HEADER_H_
#define _HEADER_H_
#include <windows.h>
#ifndef _SOME_FLAG_
extern "C"
{
#endif
BOOL foo(DWORD *lpdwParam1, DWORD *lpdwParam2);
#ifndef _SOME_FLAG_
}
#endif
#endif
library.lib(這是可能與VC編譯導入庫++,有library.dll設備上)
從「DUMPBIN /所有庫中的一些輸出。 LIB」
2DA0 [email protected]@[email protected]
2DA0 [email protected]@[email protected]
Archive member name at 2DA0: library.dll/
correct header end
Version : 0
Machine : 1C2 (Thumb)
SizeOfData : 0000002B
DLL name : library.dll
Symbol name : [email protected]@[email protected] (int __cdecl foo(unsigned long *,unsigned long *))
Type : code
Name type : undecorate
Hint : 14
Name : foo
我能夠在VS2k5(安裝的Windows Mobile SDK的需要...)使用該SDK但cegcc發編譯金正日。
我試圖編譯並將它鏈接爲C和Cpp。有和沒有_SOME_FLAG_定義(C編譯此標誌設置失敗extern「C」當然)。
的結果是:
undefined reference to `foo'
當C編譯或CPP與外部的 「C」 和
undefined reference to `foo(unsigned long*, unsigned long*)'
將cpp而不的extern 「C」編譯編譯。
編譯:
gcc -O2 -Wall -Wextra -pedantic -Wno-long-long -g -c -DUNICODE -D_UNICODE -Ic:\inc sample.c
鏈接:
gcc -static -mconsole -o sample obj\sample.o -lc:\lib\library.lib -laygshell
當我的.cpp編譯我只是改變sample.c文件到sample.cpp的(只有主用簡單的FOO調用)。
它看起來像有一個mangling問題(vC++ vs gcc)。我試過添加__attribute__((dllimport))
和__attribute__((cdecl))
我該如何解決這個問題?有任何想法嗎?