Why does pjsua build shows error after Setting Windows(/SUBSYSTEM:WINDOWS) as Linker-> Subystem property in Visual Studio 2017 - visual-studio-2017

I tried compiling pjproject-2.9 as per the doc on Windows 10 x64. I tried the following commands. All ran successfully
(i) ./configure (ii) make && make install
I'm using Visual Studio 2017. For building the projects, I followed the procedure given in the above document for VS 2015:
opened pjproject-vs14.sln solution file ---> Set pjsua as Startup Project ---> Set Win32 as the platform ---> Select Debug or Release build ---> Build the project.
Created a empty config_site.h file in pjproject/pjlib/include/pj
I have made the following changes in the pjsua property:
1. Configuration Properties --> General-->Windows SDK Version 10.0.18362.0
Configuration Properties --> General-->Platform Toolset Visual Studio 2017(v141)
Project Defaults--> Configuration Type --> Application(.exe)
Project Defaults--> Use of MFC --> Use Standard Windows Libraries
Project Defaults--> Character Set --> Use Multi-Byte Character Set
Project Defaults--> Common Language Runtime Support --> No common language runtime support
VC++ Directories --> Include Directories --> (my sdl2 include path and python include path)
VC++ Directories --> Library Directories --> (python libs path)
C/C++ --> General --> (addded SDL2 include path)
Linker --> General --> Additional Library Directories --> ( added sdl2 libx86 path)
Linker --> Input --> Additional Dependencies --> (added SDL2.lib, SDL2main.lib )
Linker --> System --> Subsystem --> Console(/SUBSYSTEM:CONSOLE)
Linker --> Advanced -->Target Machine --> Not Set
pjsua --> Build Dependencies --> Project Dependencies --> Selected All
When i set Linker --> System --> Subsystem --> Console(/SUBSYSTEM:CONSOLE) it is build successfully. But i need to build this as Windows(/SUBSYSTEM:WINDOWS) it shows me the error.
Note: followed this link to set the properties for SDL2. I also went through other links like wikihow..everwhere it is mentioned to use Windows(/SUBSYSTEM:WINDOWS) only. I need to build this with Windows(/SUBSYSTEM: WINDOWS) only
These are the errors i got:
LNK2019 unresolved external symbol _SDL_main referenced in function _main_getcmdline pjsua ...\pjproject-2.9\pjsip-apps\build\SDL2main.lib(SDL_windows_main.obj) 1
LNK1120 1 unresolved externals pjsua ...\pjproject-2.9\pjsip-apps\bin\pjsua-i386-Win32-vc14-Release.exe 1```
Please Note: I added/changed property one by one and generated a build. To see which of these is creating the error. only after changing from CONSOLE(/SUBSYSTEM: CONSOLE) to WINDOWS(/SUBSYSTEM:WINDOWS), I got those error.
Every time before pjsua build, i do pjsua clean. Still, I get these errors
All these error are linker related. Is there any property I have to change?

Related

Linker Tools Error while configured and build wxWidgets Visual Studio 2017

Not able to configure wxwidgets in Visual Studio 2017.
Followed these steps.
From wxwidgets website, downloaded Source Code 'Windows 7Z' file, Version 3.1.3.
Run the wx_vc15.sln from build ->msw in Visual Studio 2017.
Build the Debub, DLL Debug, DLL Release, Relese successfully with Platform x86.
In Microsoft Visual Studio 17 V15.9.20, created an empty project. Added a simple wxWidgets program.
In project properties made the below changes
- In All Configurations with Platform Win32, Set the Configuration Properties -> Character Set to Use Unicode Character Set
C/C++ -> Additional Include Directories -> $(WXWIN)\include\msvc;$(WXWIN)\include;
C/C++ -> Preprocessor -> Preprocessor Defenitions -> __WXMSW__;WXUSINGDLL;_DEBUG
Linker -> Additional Library Directories -> $(WXWIN)\lib\vc_dll
Made these changes in Environment Variables
In User variables
Add a new variable WXWIN and set its value to C:\Users\varun\Desktop\workspace\wxWidgets-3.1.3.
Path -> C:\Users\varun\Desktop\workspace\wxWidgets-3.1.3\lib\vc_dll.
In project properties Release Configurations, made these changes
C/C++ -> Preprocessor -> Preprocessor Defenitions -> __WXMSW__;WXUSINGDLL;NDEBUG;
There is no code error but Linker Tools Error
Error (active) E1097 unknown attribute "no_init_all" WxWidgets_Application_5 C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h
Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ) WxWidgets_Application_3 C:\Users\varun\Desktop\workspace\visual_studio_projects_2017\WxWidgets_Application_3\WxWidgets_Application_3\MSVCRTD.lib(exe_main.obj)
Error LNK1120 1 unresolved externals WxWidgets_Application_3 C:\Users\varun\Desktop\workspace\visual_studio_projects_2017\WxWidgets_Application_3\Debug\WxWidgets_Application_3.exe
What could have gone wrong?
The first error you show is not an error at all but just some IntelliSense noise, see this bug report. The real error is not being able to find _main which seems to indicate that you're building a console application (see Properties\Linker\System\SubSystem option), so it should be fixed by just making it a Windows application instead.
Also, while I don't see anything really wrong with your setup, I would still recommend using the official instructions instead. Notably in your case it should be as simple as:
If you use MSVS 2010 or later IDE for building your project, simply add wxwidgets.props property sheet to (all) your project(s) using wxWidgets. You don't need to do anything else.

How to add Include directories in Visual Studio while cross-compiling to a Raspberry Pi?

I'm working on a c++ project on my Raspberry Pi. I'm using Visual Studio 2017 to cross-compile the project to my Raspberry.
But when I try to compile the project, I get the error"cannot open source file" in lots of header files.
I already managed to compile simple projects, but now I need to Include Directories and I don't know the proper syntax to set, on Visual Studio's project properties page, the Include Directories to tell the compile where the header files are stored.
For the PCL library, e.g., I was able to include directories using '$(INCLUDE_PCL)'.
But when I try to include pi's directory '/usr/Include/ni' I can't correctly set the absolute path. Here's an screenshot of my properties page (https://ibb.co/G2dszrx). I haven't set the Linker directories yet, since I'm currently getting errors on the compiling phase.
Does anyone knows how to set absolute path to include directories correctly?
EDITED:
Trying to figure this out, I created a new project (Proj) in which I include the file 'try.cpp' stored in the raspberry's "home/pi/projects" folder. This project is in the "/home/pi/projects/Proj" folder.
In the project property page, I have:
Configuration Properties>General>Remote Build Root Directory --> ~/projects
Configuration Properties>General>Remote Build Project Directory --> $(RemoteRootDir)/$(ProjectName)
C/C++>General>Additional Include Directories --> $(RemoteRootDir)
When I compile the project this path gets created correctly, and the project is saved at the correct place, even if go further into more folders in the remote build project directory, but it can't find the include file "try.h".
How can Visual Studio know where to save the project using '$(RemoteRootDir)', but is not able to add that path include directory?
After some searching I managed to correctly add the Additional Include Directories, and Additional Libraries.
Firstly I was also using OpenNI, to work with the PCL. After many tries, I discovered that OpenNI was not correctly installed. So I managed to install it with apt-get.
Secondly, If you want to include the "/home/pi/someDIR" directory at the Raspberry device, just add "/home/pi/someDIR" to Visual Studio's additional include directories.
For you still trying to achieve this, Merlyn Oppenheim, from visual studio, set up a sample project using VS 2019 and Raspberry PI template -> https://github.com/merlynoppenheim/sample-rasp-inc-headers
For this sample project the Visual Studio properties page should have:
C/C++ -> General -> Additional Include Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/include;%(AdditionalIncludeDirectories)'
C/C++ -> Linker -> General -> Additional Library Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/debug/lib;%(AdditionalLibraryDirectories)'
C/C++ -> Linker -> Input -> Library Dependencies = 'wiringPi;sqlite3;pthread;dl'

How do I use cURLpp with Visual Studio?

I'm using VS 2019, have downloaded all the cURLpp headers, put them and the cURL headers in an include folder and added this include directory under Project Properties -> Additional Include Directories. When I try to build example00.cpp from the cURLpp site, I get errors saying I have an unresolved external symbol. I've never used a third party library with C++ before, so please explain like I'm an idiot. Should I have a dll or lib file?
I use vcpkg to install curlpp, and I find that my project configuration in visual studio is x64, if I use x86 curlpp it will get build error, I need to use x64 curlpp then build sucess.
This is the include step:
Run cmd command: vcpkg install curlpp:x64-windows
goto Project > Configuration Properties -> Linker -> General -> Additional Library Directories, add yourVcpkgFolderPath\vcpkg\installed\x64-windows\lib\
goto Project > Configuration Properties -> Linker -> Input -> Additional Dependencies, add curlpp.lib
Then build the project, it should build success.

Linker Issues VS2015. LNK2019 and LNK2001 unresolved external symbol

I am trying to extend my knowledge of constrain programming and I want to build a simple example using google's or-tools in VS2015.
However I am constantly nagged by those linker errors. LNK2019 and LNK2001. Why is linking in VS so darn hard.
Google's or-tools comes in a perfect folder, with an include subfolder and lib subfolder with one single .lib file.
I have added Additional Library Dependencies.
Configuration Properties -> Linker -> General Additional Library Dependencies : C:\PATH\or-tools.VisualStudio2013-64b\lib
Set the Input under the Linker properties section.
Configuration Properties -> Linker -> Input Additional Dependencies : ortools.lib
Infomed VC++ where the include directory is.
Configuration Properties -> VC++ Directories : C:\PATH\or-tools.VisualStudio2013-64b
However it is still throwing link errors when building the solution. What am I missing here.
Thanks in advance.
edit:
spelling
Since the VS2013 and VS2015 compiler versions are incompatible, you have to build the lib from source. Though beware that this might entail a bit more work when linking with VS2015. Specifically I've had to manually resolve the following issues:
Change protobuf-3.0.0-beta-1 to protobuf-3.0.0-beta-2(bonus. not really necessary)
gflags 2.1.2 failed to compile due to a conflict of names around snprintf. To resolve this download the latest gflags version from GitHub and overwrite the one in %OR_TOOLS%\dependencies
Look up all VS solution files (.sln) in dependencies\sources\cbc-2.9.7 and convert to VS2015 format by simply double clicking them and following the instructions.
Add the following code to makefiles\Makefile.port
ifeq ("$(VisualStudioVersion)", "14.0")
VISUAL_STUDIO=2015
VS_RELEASE=v140
VS_COMTOOLS=140
else
...
endif
Replace Visual Studio 12 2013 with Visual Studio 14 2015
Rerun make third_party after each step.
Or you can just download the end result, linked on Windows 10 x64 VS2015 update 1. I've included the whole folder after running make third_party && make cc.

Tinyxml - Link errors when targeting x64 platform

I'm using tinyxml library for parsing XML files in my project. When I try to target x64 platforms I get LINKER errors and here is one fo them:
Error 4 error LNK2001: unresolved external symbol "private: static
struct TiXmlString::Rep TiXmlString::nullrep_"
(?nullrep_#TiXmlString##0URep#1#A) ClassThatUsesTinyXML.obj
Update : I figured that the x64 version of tinyxml was not installed but when I tried to build the library for x64 platforms I got this error :
LNK1561: entry point must be defined
Instead of building tinyxml for x64 platforms and then adding tinyxml.h and tinystr.h to the project, I just added all the library files including the .cpp files and now I can target x64 platforms, the library is, in fact, being built when I build the whole project.
It does not look like tinyxml supports shared library builds out of the box.
Here are the steps that I followed to build a DLL from the tinyxml 2.6.2 sources:
Open the provided SLN file, tinyxml.sln, in MS Visual Studio Express 2012 for Windows Desktop. Elect to convert the old project files to the new format when prompted.
From "Solution Platforms", select "Configuration Manager..."
From "Active solution platform:" select "<New...>"
In "Type or select the new platform:" select "x64" if not already selected. Make sure to copy settings from the "Win32" configuration. Click OK. Click Close to exit the Configuration Manager.
Right click on the tinyxml project in Solution Explorer. Select "Properties".
For "Configuration:", select "All Configurations". Similarly, for "Platform:" select "All Platforms".
On the Configuration Properties → General page, change "Configuration Type" to "Dynamic Library (.dll)". Change "Target Extension" to ".dll". Click OK to exit the tinyxml Properties Pages dialog.
Select the "Release" configuration and "x64" platform.
Right click on the tinyxml project in Solution Explorer again and select "Rebuild".
Within tinyxml_2_6_2\tinyxml\x64\Release you will find tinyxml.dll, but no import library (tinyxml.lib). This is because no symbols are exported. See How do I build an import library (.lib) AND a DLL in Visual C++?
If you want to go the shared library route, you will need to export the desired symbols via the MSVC-specific __declspec(dllexport) modifier. See Symbol Visibility in Windows.
The errors occurs when you define TIXML_USE_STL for the compilation of the library, but not for the sources that link to the library. The end result is that the library is compiled with different code from the sources using the library.