UIKit0 / pdfium

Automatically exported from code.google.com/p/pdfium
0 stars 0 forks source link

Compilation of pdfium_test failed with shared pdfium library on Windows Win32 with Visual Studio 2010 #127

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Change from static_library into shared_library in pdfium.gyp
2. Add each library dependency into link_settings : libraries and 
AdditionalLibraryDirectories to '$(OutDir)/lib/'
3. Open build/all.sln 
4. Select Release type, Win32 architecture
5. Compile pdfium target
6. Compile pdfium_test target

What is the expected output? What do you see instead?
>pdfium_test.obj : error LNK2019: unresolved external symbol _FPDF_RenderPage 
referenced in function "void __cdecl WriteEmf(void *,char const *,int)" 
(?WriteEmf@@YAXPAXPBDH@Z)
>pdfium_test.obj : error LNK2019: unresolved external symbol 
_FPDF_GetPageHeight referenced in function "void __cdecl WriteEmf(void *,char 
const *,int)" (?WriteEmf@@YAXPAXPBDH@Z)
>pdfium_test.obj : error LNK2019: unresolved external symbol _FPDF_GetPageWidth 
referenced in function "void __cdecl WriteEmf(void *,char const *,int)" 
(?WriteEmf@@YAXPAXPBDH@Z)
>pdfium_test.obj : error LNK2019: unresolved external symbol _FPDFAvail_Destroy 
referenced in function "void __cdecl RenderPdf(class 
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> 
> const &,char const *,unsigned int,struct Options const &)" 
(?RenderPdf@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@
PBDIABUOptions@@@Z)
>pdfium_test.obj : error LNK2019: unresolved external symbol 
_FPDF_DestroyLibrary referenced in function _main
>pdfium_test.obj : error LNK2019: unresolved external symbol 
_FSDK_SetUnSpObjProcessHandler referenced in function _main
>pdfium_test.obj : error LNK2019: unresolved external symbol _FPDF_InitLibrary 
referenced in function _main
>..\build\Release\pdfium_test.exe : fatal error LNK1120: 28 unresolved externals

instead of compiled pdfium_test.exe binary file

What version of the product are you using? On what operating system?
Visual Studio 2010
Windows 7 x64

Please provide any additional information below.
After successful compilation of shared library pdfium.dll there is pdfium.lib 
file.
I explored pdfium.lib and it has every symbol, which is required, with correct 
machine X86. Compilation in x64 architecture is working without problem.

Original issue reported on code.google.com by mar...@mikita.eu on 3 Mar 2015 at 1:56

GoogleCodeExporter commented 9 years ago
You need to define FPDFSDK_EXPORTS in both the pdfium project and the dependent 
projects for the symbols to be exported and imported correctly.

That said, I think you'll run into issues using pdfium as a dll; i'm not sure 
is ready for that yet (and I'm not sure it's headed in that direction either)

Original comment by lultimou...@gmail.com on 3 Mar 2015 at 10:00

GoogleCodeExporter commented 9 years ago
I tried static library, I h ave FPDFSDK_EXPORTS in pdfium project and every 
dependent project (pdfium_test and fpdf*, fx*, etc projects).
But still can't compile win32 pdfium_test binary (using only pdfium.lib).
I tried x64 static library, pdfium_test + pdfium.lib creates pdfium_test.exe 
which is working.

There is something wrong with Win32 version, but I do not know what and why, I 
do not understand gyp very well, neither the whole code of pdfium

Original comment by mar...@mikita.eu on 3 Mar 2015 at 12:29

GoogleCodeExporter commented 9 years ago
Finally, I fixed this with the following patch:
Win32 configuration requires __stdcall, when it is included in project (not 
exported), but this is not required in x64 configuration

--- a/fpdfsdk/include/fpdfview.h
+++ b/fpdfsdk/include/fpdfview.h
@@ -112,7 +112,12 @@ typedef const FS_RECTF*    FS_LPCRECTF;
 #define STDCALL __stdcall
 #else
 #define DLLEXPORT
+#if !defined(_WIN64)
+// On Windows Win32 (not x64) requires __stdcall convention
+#define STDCALL __stdcall
+#else
 #define STDCALL
+#endif  // !defined(_WIN64)
 #endif

 extern const char g_ExpireDate[];

Original comment by mar...@mikita.eu on 7 Mar 2015 at 1:03