unresolved symbols after converting VS2012 Windows 8 Metro solution to VS2013 (on Windows 8.1) - microsoft-metro

I have a question, which I'm currently unable to tackle effectively since I'm still unfamiliar with Metro app development. So please bear with me :)
Long story short, I have a large, complex VS2012 Metro app managed+native solution (currently built on Windows 8) into VS2013 targeting Windows 8.1.
I imported the solution into VS2013 (hosted on Windows 8.1), and run the conversion for it and all the sub projects therein. Stuff compile, but it is with the linker that we run into problems. This is an example of the linker errors we get:
error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function <blahblahblah>
error LNK2019: unresolved external symbol __imp___mbsrchr referenced in function <blahblahblah>
error LNK2019: unresolved external symbol _getenv referenced in function <blahblahblah>
error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function <blahblahblah>
error LNK2019: unresolved external symbol __imp___endthreadex referenced in function <blahblahblah>
error LNK2019: unresolved external symbol __imp___mbsrchr referenced in function <blahblahblah>
error LNK2019: unresolved external symbol __imp___mbsnbicmp referenced in function <blahblahblah>
error LNK2019: unresolved external symbol __imp___dupenv_s referenced in function <blahblahblah>
The thing is that for every single symbol that is 'missing', we can see the that the declaration is present in the MS Windows header files supplied with VS2013. Inspecting the references in each sub-project shows that they are referencing the Windows 'core' libs.
Any ideas why this is happening? Thanks.

we can see the that the declaration is present in the MS Windows header files supplied with VS2013. Inspecting the references in each sub-project shows that they are referencing the Windows 'core' libs
It is going to be difficult to diagnose what went wrong with this little information, but it is pretty clear that you are looking in the completely wrong corner for this problem. The missing symbols are not Windows api functions, they are C runtime support functions. They are only used in a C++ project, you've been looking at .NET projects.
So you'll need to focus on the one project that generates these linker errors, it is a C++ project. The linker command that's issued to get it to link to the .lib that has these symbols is completely automagic so there isn't much that can go wrong. The very first thing to do is to force a complete rebuild so it won't use outdated .obj and .lib files that were left over from a previous build in VS2012. Right-click the project and choose Rebuild.
And it is worth taking a look at the .vcxproj file for this project with a text editor (like Notepad) and ensure that the conversion went properly and made the correct changes:
the ToolsVersion property must be changed from "4.0" to "12.0"
the MinimumVisualStudioVersion property must be changed from 11.0 to 12.0
two new properties are added, ApplicationType (Windows Store) and ApplicationTypeRevision (8.1)
every configuration's PlatformToolset property must be changed from v110 to v120
There is a log file in the Debug\projectname.tlog directory named link.read.1.tlog that contains diagnostics, it shows all the .lib files that the linker uses. It must contain this line:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\VC\LIB\STORE\VCCORLIBD.LIB
Which is the .lib file that contains these symbols.

Related

How do I reference a UWP+NET46 portable library from a .NET 4.6 console application?

I have a portable class library project that targets .NET 4.6 and Universal Windows Platform. This class library contains just one class with the following line of code in its constructor:
Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
Now I create a new .NET 4.6 console application project in the same solution and add a project reference to the portable class library. Calling the method that houses the above line of code results in the following exception at runtime:
Could not load file or assembly 'System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
What am I doing wrong here? There are no compile-time errors or warnings.
Things I have tried: add missing(?) NuGet package manually
It seems that System.IO.FileSystem is a library delivered via NuGet, as part of the Microsoft.NETCore mega-package. Okay, perhaps I need to explicitly add this package to any project that uses my portable class library. I attempt to do so.
Could not install package 'Microsoft.NETCore.Platforms 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
No luck with this approach.
Things I have tried: create a project.json file
While there is no clear info on the web, I read a few tidbits about a new project.json based NuGet harness or build system. Just to experiment, I created the following project.json file in my console application project:
{
"dependencies": {
},
"frameworks": {
"net46": { }
},
"runtimes": {
"win-anycpu": { }
}
}
It works! The runtime error goes away! However, I soon found that this was either not the right solution or not a complete solution. I started writing some code to read configuration section values, which involved making use of the IConfigurationSectionHandler interface, and got the following compile-time error:
error CS0246: The type or namespace name 'IConfigurationSectionHandler' could not be found (are you missing a using directive or an assembly reference?)
This interface is part of the System assembly. I see a reference to this assembly, but it has a yellow exclamation mark icon, and a warning appears in the warnings window:
The referenced component 'System' could not be found.
This is where I ran out of ideas. Am I missing something totally obvious?
I have found the solution. My initial attempt was to install the Microsoft.NETCore package into the console application, resulting in the error shown in my original post.
However, if I install only the narrowly-scoped packages, e.g. System.IO.FileSystem, then I achieve success and the application works correctly. Apparently there is something special about the Microsoft.NETCore "master package" that prevents it from correctly installing into dependent projects.

Code generation of linked blocks in Simulink

I am trying to generate code of my Simulink Model. The model contains linked blocks and Level 2 S-functions.
I am getting the following error when I press the Build Model Button
MyFluidProp_mod6.obj : error LNK2019: unresolved external symbol "double __cdecl pneu_fluids_PureGasProps_cp(double,class FluidProps &)" (?pneu_fluids_PureGasProps_cp##YANNAEAVFluidProps###Z) referenced in function "double __cdecl cp_Fcn(double,class FluidProps &)" (?cp_Fcn##YANNAEAVFluidProps###Z)
Update:
After tracking all required source files, and copying them to the current folder, I end up with the actual error:
C:\Program Files\Microsoft SDKs\Windows\v7.1\\include\winnt.h(135) : fatal error C1189: #error : "No Target Architecture"
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl.EXE"' : return code '0x2'
Stop.
From previous posts, it appears that winnt.h has to be replaced by windef.h. But since it used internally (not by any of my source codes), I can't change it.
This is most probably to a missing link to one of the used libraries. But since I cannot supply any additional commands to the Build Button, I cannot specify the link. I also must admit that I didn't understand exactly the error message meaning.
Can anyone help?
Your most likely not telling the compiler where to look for the library containing the function in question. This is done on the Configuration Parameters -> Code Generation -> Custom Code tab. If you right click on the words "Include Directories:" then you can bring up the help, explaining what to put into where.

Issues with g++ and Eclipse on Linux - unresolved symbols

I am running Ubuntu 64bit version, and downloaded the latest 64bit Eclipse.
Installed g++ along with build-essential. Tested g++ to make sure it works from terminal, and it works fine.
alex#ubuntu:~/Desktop$ g++ test.cpp -o test
alex#ubuntu:~/Desktop$ ./test
Hello World!alex#ubuntu:~/Desktop$
However, trying to build simple C++ Hello Word project(one of the default projects that comes with Eclipse), I am getting error.
Description Resource Path Location Type
Program "g++" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Builtin Compiler Settings] options C/C++ Scanner Discovery Problem
I have added Environment variable named g++ with value /usr/bin/g++ and the above error went away, however, now I am getting unresolved errors, though project compiles and in the Console shows !!!Hello World!!!
Description Resource Path Location Type
Symbol 'endl' could not be resolved test_hello.cpp /test_hello/src line 13 Semantic Error
Symbol 'cout' could not be resolved test_hello.cpp /test_hello/src line 13 Semantic Error
Symbol 'std' could not be resolved test_hello.cpp /test_hello/src line 10 Semantic Error
Have I correctly entered Environmental variable ?? How can I get fix the "unresolved" error ?? Thanks !
When compiling there are two important things to consider:
1.) Is my path up-to-date with executables?
2.) Is my library path correct?
It appears you satisfy 1.) but not 2.)
The unresolved symbol error means that Eclipse cannot find your library via LD_LIBRARY_PATH or some other medium. It's attempting to locate the standard compiled C++ library.
How did you install g++?
Kindly do this and post the results:
Project > Properties > C/C++ Build > Environment
If everything there appears nominal, you can try
/sbin/ldconfig
which should hopefully re-parse your system library paths and might update your environment.

"Undefined symbols for architecture i386" on unit tests

I'm getting the following error only when I try to build the unit tests of an iPhone static library:
Undefined symbols for architecture i386:
"std::terminate()", referenced from:
-[ZipArchive dealloc] in libMyProject.a(ZipArchive.o)
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in libMyProject.a(ZipArchive.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Building the original project works fine.
What can I be missing?
It should be noted that ZipArchive is a .mm file that references the libz.dylib framework, which is referenced both in the original project and in the test project.
Additionally, the usual Build Settings suspects have the following values:
Framework Search Paths: "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"
Other Linker Flags: -all_load -lxml2 - ObjC
Header Search Paths: /usr/include/libxml2
I found the solution in this post.
For some reason that eludes me, the compiler needed the ZipArchive.mm file to be renamed to .m when the static library is used in another project (the test project, in this case).
This typically occurs for one of two reasons:
You copied a framework or system header directly to your project folder instead of adding it with a reference through XCode
You've installed multiple SDKs, and the wrong framework or header is being referenced. Most frameworks aren't "Developer" frameworks. SenTestingKit.framework is an example of a developer framework, UIKit.framework isn't. Oddly, there are two different places that Developer Frameworks exist. In the /Developers/~ folder in XCode, and also in the SDK Developers folder. The default behavior is to reference the framework in XCode's developer folder. To override this, enter "$(SDKROOT)/Developer/Library/Frameworks" in "Framework Search Paths". Or in the case of an imported header or library, go the corresponding field and add "$(SDKROOT)/..."
Make sure your search paths are the same correct for all Targets:
If you are using multiple SDKs, the wrong version of the Developer Frameworks could get added (like SenTestingKit). Manually enter the the correct one under Framework Search Paths with
$(SDKROOT)/Developer/Library/Frameworks

Struggling with Xcode 4

I've recently downloaded Xcode 4 and now two of my projects that were working perfectly fine before have started giving me errors. Both errors are effectively to do with linking options, but I can't figure out how to change these options and get rid of the errors.
The first problem is with a project written in C++ using the SDL_ttf and SDL_image frameworks. The project builds correctly, but when I try to run, it gives me the following warnings on the console:
warning: Unable to read symbols for #executable_path/../Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf (file not found).
warning: Unable to read symbols from "SDL_ttf" (not yet mapped into memory).
warning: Unable to read symbols for #executable_path/../Frameworks/SDL_image.framework/Versions/A/SDL_image (file not found).
warning: Unable to read symbols from "SDL_image" (not yet mapped into memory).
Since the files are not being found, the executable cannot load any images making it exit straight away when I try to load images. I think the issue here is that the frameworks are not in the directory above the executable, they are in /Library/Framework/ which worked fine before in Xcode 3.2. How do I resolve this?
The second problem comes when compiling an application I wrote for iOS. Along with giving me a bunch of warnings about depracated code on iOS 5, which I will deal with later, it fails to build due to a linker error which I have no clue how to resolve, it says:
ld: library not found for -lz.1.2.3
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
I can answer the second question.
-lz.1.2.3
should be
-lz
You might have accidentally added the zlib.1.2.3.dylib to the project's "link binary with libraries" build phase. You should use the standard zlib without any version in its filename, or simply add -lz to the Other Linker Flags under Build Settings and not add zlib in the "link binary with libraries" build phase.
As for the missing frameworks my best guess is that it has to do with the relative path, ie if you can get rid of the /../ part and instead provide an absolute path that might resolve the issue.