如果你的程式是 /MDd 那要在 C/C++ --> Code Generation --> Runtime Library 改成 /MTd 才不會出現
warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs
附表 ( Visual C++ CRT )
Reusable Library Switch Library Macro(s) Defined ---------------------------------------------------------------- Single Threaded /ML LIBC (none) Static MultiThread /MT LIBCMT _MT Dynamic Link (DLL) /MD MSVCRT _MT and _DLL Debug Single Threaded /MLd LIBCD _DEBUG Debug Static MultiThread /MTd LIBCMTD _DEBUG and _MT Debug Dynamic Link (DLL) /MDd MSVCRTD _DEBUG, _MT, and _DLL 如何看一個Library 是用什麼選項編譯的呢? dumpbin /all xxx.obj or xxx.lib 在 section RAW DATA #1
LNK1103: debugging information corrupt; recompile module
if compile with vs 2008, and later try to build and link with vs 2005, this error appear
solution: recompile with vs2005 ok
When using instrument profiling on Visual Studio 2005, VSP file may grow up more than 4G
and VSP error 1370 appear. But it seems on VS 2008 produce much smaller VSP file ( around 2G) and ok.
1.
Compile & R
2. Build on VS2008 command line
must set include & lib path
EX: build libjpeg
cjpeg 等 exe 無法build 因為其裏面有呼叫 fclose() 等函數
而fclose 在ce/include 中沒有stdio.h 在sdk\include\mipsii 下有定義
也是一行 #include "stdlib.h"
WINCE 下的 fclose 應該是 link 到 coredll.dll header stdlib.h
所以把 cjpeg link 到 coredll.lib 應該就ok
cjpeg.exe link error
1. 少 fclose() --> link coredll.lib
2. 少 exit() --> corelibc.lib
3. unresolved external symbol __GSHandlerCheck --> compile 選項加 /GS-
4. unresolved external symbol getenv --> jmemmgr.c 使用了getenv, 定義NO_GETENV
5. unresolved external symbol WinMain in WinMainCRTStartup --> default link entry 是 WinMainCRTStartup, link option 加 /ENTRY:mainACRTStartup
jconfig.h 把 USE_SETMODE undef
stdlib.h 沒有 getenv 所以要定義 NO_GETENV
note:
如果程式有include 到 \vc\include\*.h 的話 如 9.0\vc\include\io.h
通常程式需要修改 因為使用了 embedded vc 沒有支援的函式、標頭檔
才會跑到 vc\include\*.h
ex: Build libtiff ( MIPSII)
crtdefs.h(100) : fatal error C1189: #error : ERROR: Use of C runtime library internal header file
in crtdefs.h
#if !defined(_CRTBLD) && !defined(_WIN32_WCE)
/* This version of the header files is NOT for user programs.
* It is intended for use when building the C runtimes ONLY.
* The version intended for public use will not have this message.
*/
#error ERROR: Use of C runtime library internal header file.
#endif /* _CRTBLD && !_WIN32_WCE */
so we should define _WIN32_WCE
VC\INCLUDE\ctype.h(175) : error C2085: 'is_wctype' : not in formal parameter list
there is no ctype.h in vc\ce\include
so by viewing IDE setup
I find it use C:\Program Files\Windows CE Tools\wce500\STANDARDSDK_500\include\MIPSII\ctype.h
and in this file, it simply #include "stdlib.h"
so C:\Program Files\Windows CE Tools\wce500\STANDARDSDK_500\include\MIPSII should
be before vc\include
port is ok
later build libtiff dir
error c2375: 'qsort' : redefinition; different linkage
in Search.h & stdlib.h
in stdlib.h there is no _CRTIMP in front of qsort, others are the same
Look into search.h
/* Define _CRTIMP */
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
so shouldn't define _DLL? yes!
so use /MT instead of /MD in nmake.opt
next,
C:\Program Files\Windows CE Tools\wce500\STANDARDSDK_500\include\MIPSII\winnt.h(2975) : error C2061: syntax error : identifier 'PCONTEXT'
should define _MIPS_ in nmake.opt
後來 build 到 tif_stream.cxx 又出現
>C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\include \xiosbase(209) : error C2470: 'ios_base' : looks like a function definition, but there is no parameter list; skipping apparent body 問題 Google 了一下總算找到 vc\ce\include 必需在 STANDARDSDK_500\include 之前 就成功 compile 了 剩最後link error LINK : fatal error LNK1195: target machine 'MIPS' requires '/SUBSYSTEM:WINDOWSCE' /subsystem:windowsce 好像是只在link dll 時會有問題 在link static library 時沒加也沒問題 及一些 warning in tif_unix.c 主要是 C:\Program Files\Windows CE Tools\wce500\STANDARDSDK_500\include\MIPSII\specstrings.h(48) : warning C4005: '__in' : macro redefinition C:\Program Files\Microsoft Visual Studio 8\VC\ce\include\sal.h(520) : see previous definition of '__in' C:\Program Files\Windows CE Tools\wce500\STANDARDSDK_500\include\MIPSII\specstrings.h sal.h 及 specstrings.h 兩個檔案有一堆重複的macro 經檢查 sal.h 發現當 _WIN32_WCE == 0x500 時 這些macro的定義和 specstrings.h 一樣 為null 所以定義 _WIN32_WCE 還不夠 要定義 _WIN32_WCE=0x500 1. 改nmake.opt, OPTFLAGS = /Ox /MT /EHsc /W3 /D_WIN32_WCE=0x500 /D_MIPS_ /DDEPRECATE_SUPPORTED comment #USE_WIN_CRT_LIB = 1 2. 改 libtiff/tif_config.h HAVE_FCNTL_H HAVE_SYS_TYPES_H HAVE_IO_H 拿掉 3. 因為很多檔案使用 fcntl.h 中的定義如 O_RDONLY O_WRONLY 我們又沒有fcntl.h (WINCE下) 所以把vc\include\fcntl.h定義 copy 到 tiffiop.h中 #ifdef HAVE_FCNTL_H # include#if !defined(_WIN32)#else ... ... #endif 4. 剩下 tif_win32.c GlobalAlloc GMEM_FIXED 的修改 ( WinCE 不支援 Global Heap) --> use LocalAlloc LocalFree LMEM_FIXED ... sprintf_instead_use_StringCbPrintfA ... 問題 --> define DEPRECATE_SUPPORTED http://www.ddj.com/mobile/184405528 5. 編譯成功完後下來就是編譯 dll 又出現一堆link錯誤 在nmake.opt 裏加入 LIBS = corelibc.lib 就會剩下四個 unresolved symbol bsearch _lfind __imp_CreateFileMappingA __imp_CreateFileA __imp_CreateFileMappingA --> 加入 UNICODE 定義後就消失了 __imp_CreateFileA --> 必需修改 tif_win32.c 因為它直接在source code中用 CreateFileA至於 bsearch lfind 在standard sdk 中是有 search.h 但是似乎只支援 WIN32
#error ERROR: Only Win32 target supported!
#endif
在smart device IDE 下 #include
what the hell 為什麼 libtiff.lib ok?
lib libtiff.lib --> lib 的動作只是集合所有的 obj 檔 所以沒去link unresolved symbols
link libtiff.dll --> 有link的動作
所以 沒有 bsearch 及 lfind 必須修改 tif_dirinfo.c
原來Generate DLL 是做 Link 的動作!! (建立起 import library 和 DLL 之間的關聯?)
DLL 是 PE 格式 所以也是一種EXE