I'm trying to compile a module with V8 and Node. I configured it to be dll and downloaded the source code and compiled nodejs with vcbuild.bat.
However, it throws errors like
Error 2 error LNK2028: unresolved token (0A0005F6) "class v8::Handle __cdecl v8::True(void)" (?True#v8##$$FYA?AV?$Handle#VBoolean#v8###1#XZ) referenced in function "public: static class v8::Handle __cdecl v8::Boolean::New(bool)" (?New#Boolean#v8##$$FSA?AV?$Handle#VBoolean#v8###2#_N#Z)
or
Error 6 error LNK2028: unresolved token (0A0005FE) "public: class
v8::Local __thiscall
v8::Object::GetPropertyNames(void)"
(?GetPropertyNames#Object#v8##$$FQAE?AV?$Local#VArray#v8###2#XZ)
referenced in function "class v8::Handle __cdecl
strin(class v8::Arguments const &)"
(?strin##$$FYA?AV?$Handle#VValue#v8###v8##ABVArguments#2##Z) c:\Users\aisha\documents\visual
studio 2012\Projects\Project2\Project2\EventLog.obj EventLog
what can be wrong? Seems to be related to the object HandleScope
I have built node with v8 dll on Windows (VS2010). I record what I did to share with you all and also for my reference. The packages are fresh clones from git on this day.
First you build v8 as a dll. I used the method BitCortex suggested in this page.
Build googles v8 as shared library on windows?
And then
0) Suppose you are at the root of the source tree.
1) edit vcbuild.bat (for a debug build)
Line 15 set config=Release -> set config=Debug
Line 18 set target_arch=ia32 -> set target_arch=x64
* target-arch should be the arch of your system.
Line 92 python configure %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
-> python configure %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG% --shared-v8
2) cp $(v8-dll-build)/include/*h ./src
3) cp $(v8-dll-build)/build/Debug/lib/v8.lib .
4) Build
> vcbuild nosign
5) cp $(v8-dll-build)/build/Debug/*.dll Debug
That is all there is to it.
Related
I had boost compiled & working on my Visual Studio 2022 project. After the PC was upgraded and the OS changed to Windows 11 I attempted to re-build boost and use it with the same project. Now I get linker errors, and it seems like I have tried every suggested fix posted online. Somehow it seems like the lib files are not being found, even though I have confirmed the include and lib directories are included properly, and have tried rebuilding boost with many different configurations.
The boost build produces libboost_*.lib files, for example
libboost_log_setup-vc143-mt-gd-x32-1_78.lib
libboost_log_setup-vc143-mt-x32-1_78.lib
libboost_log-vc143-mt-gd-x32-1_78.lib
libboost_log-vc143-mt-x32-1_78.lib
Here are my boost build options
x86
b2 -j 16 --stagedir=stage/Win32 threading=multi --toolset=msvc-14.3
link=static runtime-link=shared --build-type=complete architecture=x86
address-model=32
x64
b2 -j 16 --stagedir=stage/x64 threading=multi --toolset=msvc-14.3
link=static runtime-link=shared --build-type=complete architecture=x64
--address-model=64
And my Visual Studio properties
C/C++->General->Additional Include Directories
C:\Program Files\Code Libraries\boost\boost_1_78_0
Linker->General->Additional Library Directories
C:\Program Files\Code
Libraries\boost\boost_1_78_0\stage$(Platform)\lib
And here's an example of the errors
1>Logging.obj : error LNK2019: unresolved external symbol "private: static unsigned int __cdecl boost::log::v2s_mt_nt62::attribute_name::get_id_from_string(char const *)" (?get_id_from_string#attribute_name#v2s_mt_nt62#log#boost##CAIPBD#Z) referenced in function "public: __thiscall boost::log::v2s_mt_nt62::attribute_name::attribute_name(char const *)" (??0attribute_name#v2s_mt_nt62#log#boost##QAE#PBD#Z)
1>Logging.obj : error LNK2001: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt62::aux::stream_provider<char>::release_compound(struct boost::log::v2s_mt_nt62::aux::stream_provider<char>::stream_compound *)" (?release_compound#?$stream_provider#D#aux#v2s_mt_nt62#log#boost##SAXPAUstream_compound#12345##Z)
1>Logging.obj : error LNK2019: unresolved external symbol "public: static void * __cdecl boost::log::v2s_mt_nt62::attribute::impl::operator new(unsigned int)" (??2impl#attribute#v2s_mt_nt62#log#boost##SAPAXI#Z) referenced in function "class boost::log::v2s_mt_nt62::attribute_value __cdecl boost::log::v2s_mt_nt62::attributes::make_attribute_value<unsigned int &>(unsigned int &)" (??$make_attribute_value#AAI#attributes#v2s_mt_nt62#log#boost##YA?AVattribute_value#123#AAI#Z)
1>Logging.obj : error LNK2019: unresolved external symbol "public: static void __cdecl boost::log::v2s_mt_nt62::attribute::impl::operator delete(void *,unsigned int)" (??3impl#attribute#v2s_mt_nt62#log#boost##SAXPAXI#Z) referenced in function __unwindfunclet$??$make_attribute_value#AAI#attributes#v2s_mt_nt62#log#boost##YA?AVattribute_value#123#AAI#Z$0
Edit: I also wanted to mention my preprocessor variables for Debug/Win32
WIN32
_DEBUG
_CONSOLE WIN32_LEAN_AND_MEAN
_WIN32_WINNT=0x0A00
I haven't been able to find a _WIN32_WINNT value for Windows 11, and I thought maybe that could be the problem. But I'm not entirely sure that matters.
The problem is that Boost, and Boost.Log in particular, was built for a different Windows version. You need to either:
Build Boost with _WIN32_WINNT defined to the same version as you define when you build your code.
Define BOOST_USE_WINAPI_VERSION when building your code to the Windows version Boost should target, which would be lower than your _WIN32_WINNT. Also define _WIN32_WINNT or BOOST_USE_WINAPI_VERSION macro to that version when building Boost.
To define the macro when building Boost add define=macro=value to the b2 command line. For example, define=_WIN32_WINNT=0x0A00.
I was able to create a test WinApp using JsonCPP (https://github.com/open-source-parsers/jsoncpp) to parse a json file.
However, when I implemented similar in an MFC C++ project with C/C++ -> Precompiled Headers option set to Use Precompiled Header(/Yu) in VS2008, it fails with this error:
c:\users\user1\documents\visual studio 2008\projects\jsonutility\jsonutility\jsonTest.cpp(371) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
If I add '#include "stdafx.h"' to my JsonTest.cpp, I will get this error:
JsonTest.obj : error LNK2019: unresolved external symbol "public: class Json::Value & __thiscall Json::Value::operator[](char const *)" (??AValue#Json##QAEAAV01#PBD#Z) referenced in function "public: void __thiscall JsonTest::readConfig(char const *)" (?readConfig#JsonTest##QAEXPBD#Z)
I have tried for almost 2 days now but no success.
I had added the following in my Additional Include Directories:
C:\Users\User1\Documents\Visual Studio 2008\Projects\JsonUtility\ReadingJson\dist
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include
C:\usr\jsoncpp-master\include
I seems like you didn't include the JSONCPPs *.cpp file into your project (they have to be compiled and linked). If the library gets compiled to a static library, you have to tell the linker what to link.
I am having a hard time trying to use yaml-cpp 0.3.0 on my project
I downloaded yaml, and built it like http://code.google.com/p/yaml-cpp/ said, with VS 9 2008 WIN 64. So, i got the yaml-cpp.dll and the yaml-cpp.lib
I have a c++ project on VS 2010 express, and i am trying to link the library:
I go to project properties - c/c++ general and additional include directories that have yaml-cpp header files. Then i go to linker and add path to my lib directory, then I go to linker - input and add my .lib file, then i go to VC++ Directories and add path to my lib directory in Library directories and Reference directories
Then i try to build this simple code:
std::ifstream fin("test.yaml");
YAML::Parser parser(fin);
YAML::Node doc;
while(parser.GetNextDocument(doc)) {
//do nothing yet
}
I got several linking problems, like this:
error LNK2019: unresolved external symbol "public: __thiscall YAML::Node::Node(void)" (??0Node#YAML##QAE#XZ) referenced in function "public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser##QAE#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
error LNK2019: unresolved external symbol "public: __thiscall YAML::Parser::~Parser(void)" (??1Parser#YAML##QAE#XZ) referenced in function "public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser##QAE#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
Can anyone help me? I am banging my head against a wall here.
As you said you've got a DLL from YAML, I assume you specified -DBUILD_SHARED_LIBS=ON when you built with VS2008, so you ended up with a lib for dynamic linking (to the DLL at runtime) rather than static linking (at compile time).
If the above is correct, it may be differences between VS2008 and VS2010 that are causing a problem. For example, see this post here. To quickly see if this is the cause, in your VS2010 project properties, set the Platform Toolset to V90 and see if that helps.
Also, make sure you compiled both projects for the same CPU - i.e. both for 32-bit or both for 64-bit.
I'm trying to set up sound in my Ogre3D project. I have installed irrKlang 1.4.0 and added it's include and lib directories to my projects VC++ Include and Library directories, but I'm still getting a Linker error when I attempt to build. Any suggestions?
(Error 4007 error LNK2019: unresolved external symbol
"__declspec(dllimport) class irrklang::ISoundEngine * __cdecl
irrklang::createIrrKlangDevice(enum
irrklang::E_SOUND_OUTPUT_DRIVER,int,char const *,char const *)"
(_imp?createIrrKlangDevice#irrklang##YAPAVISoundEngine#1#W4E_SOUND_OUTPUT_DRIVER#1#HPBD1#Z)
referenced in function "public: __thiscall
SoundManager::SoundManager(void)" (??0SoundManager##QAE#XZ)
Okay, after looking at this for awhile it seems I was making two mistakes.
The lib directory for irrKlang is divided in two, so instead of adding (IRRKLANGDIRECTORY)\lib to my library directories, I should have been using (IRRKLANGDIRECTORY)\lib\Win32-visualStudio.
Including the lib directory wasn't sufficient, I also needed to specify the use of the irrklang library file at the top of my class (#pragma comment(lib, "irrklang.lib")).
I've been going at this problem for almost a week now and I still have 700+ errors. Definitely need all your help! Thanks.
Problem: Need to use
Cocos2dx for Windows Phone 8
in my C++/DirectX Visual Studio 2012 project that also uses C#/XAML UI.
Given: Cocos2dx-wp8 as an Application .exe project downloaded from http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Download
Solution:
Open my C#/XAML/DirectX Game1 solution .sln project in Visual Studio 2012.
Right click on solution in Solution Explorer. Add --> Existing Project...
Selected: \cocos2dx-0.13.0-wp8-0.8\HelloWorld\cocos2d.vcxproj and clicked open
Renamed the HelloWorld project to something else like "Cocos2dxWp8" and delete the HelloWorld Classes folder and all the Assets you don't want (like the squirrels and background images)
Click Properties --> Configuration Properties --> General --> Configuration Type --> from "Application (.exe) change to "Dynamic Library (.dll)"
Added new paths to Properties --> C/C++ --> Additional Include Directories -->
$(ProjectDir); $(IntermediateOutputPath); ..\cocos2dx\include;
..\cocos2dx; ..\cocos2dx\platform\third_party\win8_metro\libpng;
..\cocos2dx\platform\third_party\win8_metro\zlib;
..\cocos2dx\platform\third_party\win8_metro; ....\Cocos2dxWp8;
..\cocos2dx\platform\win8_metro;
..\cocos2dx\platform\third_party\win8_metro\freetype;
..\cocos2dx\platform\third_party\win8_metro\libjpeg;
..\CocosDenshion\include; ..\cocos2dx\platform; inc;
%(AdditionalIncludeDirectories)
Updated the paths in Properties --> Linker --> Input --> Additional Dependencies -->
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\freetype.lib;
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\zlib.lib;
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\libjpeg.lib;
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\libpng.lib;
dxguid.lib;xaudio2.lib;dxgi.lib;uuid.lib;d3d11.lib;%(AdditionalDependencies)
Updated paths in VC++ Directories:
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\freetype;
$(SolutionDir); $(ProjectDir)inc;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\CocosDenshion\include;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\zlib;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libraries;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libpng;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libjpeg;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libxml2;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\win8_metro;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\include;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx; $(IncludePath)
From here, it builds successfully!
It outputs a .dll file but no .lib file, so...
In CCPlatformMacros.h, I enabled exporting classes to dll:
#define CC_DLL __declspec(dllexport)
Yah, .lib is being written to then...
715 Errors, 772 Warnings
Error 773 error LNK2001: unresolved external symbol "public: virtual
__thiscall cocos2d::CCKeypadHandler::~CCKeypadHandler(void)" (??1CCKeypadHandler#cocos2d#UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCSpriteBatchNode.obj
Cocos2dXWp8Framework Error 774 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadHandler::~CCKeypadHandler(void)"
(??1CCKeypadHandler#cocos2d#UAE#XZ)
I've included the header file for where CCKeyHandler class is defined (inside CCKeypadDelegate.h) and CCSpriteBatchNode.h is also in the same include folder.
Class signatures look like this:
class CC_DLL CCKeypadHandler : public CCObject
class CC_DLL CCSpriteBatchNode : public CCNode, public CCTextureProtocol
Errors continue as is...
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2dorig.obj
Cocos2dXWp8Framework Error 775 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadHandler::~CCKeypadHandler(void)"
(??1CCKeypadHandler#cocos2d##UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCImage_win8_metro.obj
Cocos2dXWp8Framework
...
Error 1482 error LNK2001: unresolved external symbol "public: virtual
void __thiscall cocos2d::CCTMXMapInfo::textHandler(void *,char const
*,int)" (?textHandler#CCTMXMapInfo#cocos2d#UAEXPAXPBDH#Z) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCDrawingPrimitives.obj
Cocos2dXWp8Framework Error 1483 error LNK2001: unresolved external
symbol "public: virtual void __thiscall
cocos2d::CCTMXMapInfo::textHandler(void *,char const *,int)"
(?textHandler#CCTMXMapInfo#cocos2d#UAEXPAXPBDH#Z)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2d.obj
Cocos2dXWp8Framework Error 1484 error LNK2019: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)"
(??1CCKeypadDispatcher#cocos2d#UAE#XZ) referenced in function "public:
virtual void * __thiscall cocos2d::CCKeypadDispatcher::`vector
deleting destructor'(unsigned int)"
(??_ECCKeypadDispatcher#cocos2d#UAEPAXI#Z)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCDirector.obj
Cocos2dXWp8Framework Error 1485 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)"
(??1CCKeypadDispatcher#cocos2d#UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCLayer.obj
Cocos2dXWp8Framework Error 1486 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)"
(??1CCKeypadDispatcher#cocos2d#UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCEGLView_win8_metro.obj
Cocos2dXWp8Framework Error 1487 error LNK1120: 48 unresolved externals
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\Win32\Debug\cocos2d\Cocos2dXWp8Framework.dll
Cocos2dXWp8Framework
Solution / Project paths:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx.sln
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\GameWp8Dx\GameWp8Dx.csproj
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\GameWp8DxComponent\GameWp8DxComponent.vcxproj
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2d.vcxproj
Cocos2d Include files:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\cocos2dx\include
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\cocos2dx\platform
Object files built here:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\Win32\Debug*.obj
.dll / .lib built here:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\Win32\Debug\cocos2d
Sorry for the long post, but I hope that's enough details to get this question going. Thanks.
I created a new dynamic library project, then copied over the files. I got the .dll and .lib built, but didn't work for an ARM CPU build target (used for devices). Also, the setup for the Cocos2dx director and scene layer doesn't seem to work well with an existing C#/XAML with DirectX project that renders onto a DrawingSurfaceBackgroundGrid control. So at the end, I didn't end up using Cocos2dx in my mixed project setup.
If anyone else got better suggestions, please let me know. Thanks.
ON TOPIC:
Perhaps you did not properly set project dependencies inside your SLN ?
I got Cocos2d to partially work with XAML+D3d Interop, but because calls go back and forward from the XAMLComponent DLL to the Cocos2d DLL, it seems to be messing up pointers and memory.
Right now I tried to move all Cocos2D source files to my D3Dcomponent project, but something is terribly wrong, and I get a weird kernelbase.dll first chance exception.
OFF TOPIC:
I was also trying to put a game done over cocos2d-x on an XAML+D3D Interop project, and used the template that comes with Visual Studio 2012. However, only a smudgy background was displayed. I was using DrawingSurfaceBackgroundGrid, and found out later that on Windows Phone 8, it has some issues related to Z-order. I ended up replacing it with DrawingSurface.