Build errors with Visual C++ 2015 cross-platform - visual-studio

I'm using the new cross-platform tools in Visual C++ 2015 to build a native shared library for Android.
I had the NDK (r10d) installed before installing VS2015 so I chose not to install the NDK in VS's secondary installer. Instead, after installation I set the NDK path under Tools > Options > Cross Platform > Android.
I had a problem with VS not finding the toolchain binary - it was looking for arm-linux-androideabi-gcc.exe under [NDK_ROOT]\toolchains\arm-linux-androideabi-4.9\prebuilt\windows\bin while in my installation the file was in [NDK_ROOT]\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin. To remedy that I just renamed the windows-x86_64 directory to windows.
Now the problem is that build errors do not propagate to the Error List view. Instead, I get a single error in the Error List:
Severity Code Description Project File Line Source
Error MSB6006 "arm-linux-androideabi-gcc.exe" exited with code 1. pexeso-android C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Android\1.0\Android.Common.targets 194 Build
The only place I can view the actual errors is in the output window:
ANDROID_HOME=C:\Dev\Android\android-sdk
ANT_HOME=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Apps\apache-ant-1.9.3\
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_05
NDK_ROOT=C:\Dev\Android\android-ndk-r10d
pch.h
PexesoAndroid.cpp
PexesoAndroid.cpp: In function 'jint JNI_OnLoad(JavaVM*, void*)':
PexesoAndroid.cpp:7:9: warning: unused variable 'jcPexeso' [-Wunused-variable]
jclass jcPexeso;
^
PexesoAndroid.cpp: In constructor 'PexesoAndroid::PexesoAndroid(JNIEnv*)':
PexesoAndroid.cpp:26:2: error: invalid conversion from 'void (*)(jstring) {aka void (*)(_jstring*)}' to 'void*' [-fpermissive]
};
^
PexesoAndroid.cpp:24:18: warning: unused variable 'method_table' [-Wunused-variable]
JNINativeMethod method_table[] = {
^
PexesoAndroid.cpp: In function 'jint JNI_OnLoad(JavaVM*, void*)':
PexesoAndroid.cpp:15:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
But this view is quite useless since, for instance, I cannot double click an error and have the IDE jump to the relevant line and source file.
Is this really what they meant when they said VS will be cross-platform?

Related

LNK1181: Visual Studio cannot find object file

I am using Microsoft Visual Studio Professional 2017 15.9.29 when compiling a project.
Compilation goes well, but linker shows an error
LINK : fatal error LNK1181: cannot open
"H:\work\build\Release_x64\intermediate\plugin\Helper.obj"
I checked the file. It does not exist. Any reasonable thought would be helpful.
/P compiler option was on, and object files were not generated.

vs2017 compile error: double inclusion of header boost/config/abi_prefix.hpp

I upgraded some vc2008 projects into vc2017 projects, and replaced boost_1_47 with boost_1_64.
Vc2008 projects were correctly compiled, but vc2017 projects reported an error:
fatal error C1189: double inclusion of header boost/config/abi_prefix.hpp is an error
what does it means? And how to solve it?
I used VS2017 with vc141 toolset and windows 10 SDK

cmake generated visual studio solution failed to build

I am currently working on a project on windows 10 and was asked to use some c++ code for it. The code was written with plattform independence in mind. So I used the given cmake files to build a visual studio solution (VS 2015 Update 3). But when I try to build the solution it gives me over 900 errors and warnings.
The same project was successfully build on a mac using cmake and g++. The project itself uses a Qt gui and some additional libaries like boost.
To understand the errors you have to know, that the solution consists of 5 projects: ALL_BUILD, iModControll, iModDaemon, iModView and ZERO_CHECK
There are a lot errors like:
missing type specifier - int assumed. Note: C++ does not support default-int
inconsistent dll binding
declaration not found
unexpected token before ;
and so on...
You can see the full list here
I am very new to cmake and not an VS expert, so please help me to understand what went wrong here. Again: the code compiled perfectly under OSX.
EDIT:
I used mingw, as #MaxGo suggested. The errors and warnings were reduced after that. Here is what I have now:
warning: void DC_TermFunc()' redeclared without dllimport attribute after being referenced with dll linkage
void DC_TermFunc(void)
{
if(controller)
{
qDebug() << "Terminating iModSkynet";
runthread->terminate();
delete runthread; // This will delete the controller too
}
}
error: function 'void DC_SendData(char, char*, int)' definition is marked dllimport
IMODCONTROLLSHARED_EXPORT void DC_SendData(char oc, char* data, int length)
{
QByteArray qdata = QByteArray(data, length);
controller->sendBlenderCommunication(oc, qdata);
}
The other errors are similar. My question is: Are there any known issues when porting c++ source code to windows, why does it not show as many errors as in VS and what can I do to solve these errors?
CMake Configuration- Boost- Visual Studio - C++
Step 1: Download CMake installation file, install and save it in local disk
Step 2: Create 2 Folders in local disk a) Raw File b)Solution File
Step 3: Raw File folder- Create a Main.cpp file and paste your raw c++ code it it and save. Now in the same folder create a txt file named CMakeLists and paste the following code in it and save.
cmake_minimum_required(VERSION 3.7)
project (cmboosttest)
#find_package(Boost REQUIRED)
#include_directories(${Boost_INCLUDE_DIR})
add_executable(boosttest ${PROJECT_SOURCE_DIR}/Main.cpp)
Step 4: Open CMake choose Raw File folder in browse source and Solution File Folder in browse build.
Step 5: Click Configure. Once it succeeds, click Generate.
Step 6: When you open the Solution File folder, you can see the built solution file. Click on it and your program will open in Visual Studio. Now, build your program in VS.
Hope this helps!

How do I fix LNK1256 ALINK 80070002 The system cannot find the file specified, from Visual Studio

I am trying to compile a Visual Studio C++ project with /CLR, and I am getting the error:
Error LNK1256 ALINK operation failed (80070002) : The system cannot find the file specified.
How do I fix this?
It turns out this means the linker cannot find the file(s) specified in the 'Assembly Link Resource' field of the project properties, passed to the linker via the /ASSEMBLYLINKRESOURCE option.

Can't Install MSVCP100.dll

I'm using CMake to build a Qt based application of mine on Windows with Visual Studio 2010 Express. When configuring with cmake I get the following error:
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcp100.dll
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcr100.dll
Then when I try to compile, I'm getting this error (both trying in Visual Studio, and with msbuild):
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
C:\Users\Kurtis\sandbox\UDJ-Desktop-Client\build\src\Release\UDJ.exe : fatal error LNK1120: 1 unresolved externals
I determined that Microsoft Visual C++ 2010 Express doesn't come with the redistributable that I need. So I went to Microsoft's website to download the redistributable (both for x86 and x64). However, after installing it, I'm still getting the above configure and compile errors. Does anyone know what I'm doing wrong, or how to fix my problem?
_WinMain#16 is the entry point of a Windows GUI application, so either it's missing from your source code, or you're not writing a GUI application, in which case your linker flags are incorrect.
Since you're using qt, make sure you have the QtMain Library being linked with your project. You can do this by adding it in your call to Find_Package like so:
find_package(Qt4 4.7.0 COMPONENTS QtMain QtCore QtGui QtSQL Phonon REQUIRED)

Resources