Using existing C/C++ code in Metro App - c++

i want to use existing C/C++ Code in a Metro App. I've made a "Blank App (XAML)", include my header files etc. Everything is compiling fine, but the linker doens't find my functions and global variables that i need to initalize my stuff. I've ported my code to many platforms like iOS, Android and other without any problem linker problems.
I think the "Blank App (XAML)" project is using managed C++ is this correct? is there any trick to use unmanaged C/C++ code in managed C++? Any other idea?
Thank you in advance!
Best Mario

Related

Using a UWP library in a C++ console app

I understand that this isn't a really common use case, but my team has built a C++ UWP static library and I'd like to link it into an existing C++ console app. However, I can't find anywhere that says that this is possible, or even anyone that's asked this question. If I try naively adding a reference, it just says that "the two platforms are incompatible" (I'd imagine one is targeting UWP and the other just targets Windows).
Does anyone know if this is possible? Would save me a pretty big rewrite.
Thanks!
If your library is not portable is not possible.
If you have access code to the code of the UWP library try to port al the code to portable library and try it again.
Best Regards

Porting a C++ project into an iOS app?

project compiles fine, how do I export it as an iOS app though
I have a large C++ project that I'd like to turn into an iOS app... any tips on how I might go about doing this? What I've done so far is to use CMake to generate an XCode project. I've been able to subsequently build (and archive -- but I can't find the archives in the organizer) my project in XCode, but to my understanding this is merely using XCode as an IDE...
Is there an easy way to remedy this situation? Or do I need to reconstruct the project all over again iOS style. If so, any guides you might recommend?
.mm files compile to objective-c++.
This is how you will get c++ code to talk to all the IOS libraries, which unfortunately are only generally easily available in objective-c and swift.
So create c++ interfaces in .h or .hpp files, and back them up with an objective-c++ impl that then talks to the objective-c runtime.
To get cmake to work nicely with iOS, you'll need a toolchain file.
There is a nice collection that you can use as a starting point here:
https://github.com/ruslo/polly

Link c++ object during runtime?

I'm trying to write my first game in c++, and I want it to dynamically load everything from files. This includes the enemies, and I was wondering if there was a way to dynamically include their code at runtime, instead of linking the on compile, so that the levels are easily interchangeable. Lua might be an option but I have no clue where to start, and dll seems to be Windows-only (and I wouldn't know where to start there anyway). Can anyone help with this?
tl;dr I want to link in code to my c++ game at runtime.
For the Lua approach you first need to choose the version first. Right now there is the major version 5.1 and 5.2. My previous work was using 5.1 and for my new project I decided to update to 5.2, however I found that my favorite script wrapping tool (SWIG) does not work with 5.2. Just something to decide at the beginning, because you do not want to get a version working and then have to change it.
Lua comes with makefile build environment. My first experience of trying to build on Windows was a bit of a nightmare, did not appear to just run out-of-the-box, so I opted to create my own Visual Studio project at the time, and just include all the .C files in the project. There are two files which need to selectively included/excluded depending on how you intend to compile: lua.c and luac.c. If you are planning to embed Lua in your app, then exclude both of these files; they both contain a main() function and are designed to build console apps. Include all the rest of the C files in your project.
You should be able to compile easy from this point.
When you include the headers of Lua, keep in mind that the functions are C functions so if you are including them from C++ you need to wrap the file inclusion inside of: extern "C" {} - example: C++ Lua 5.1 Issue
Wrapping your interfaces in another topic and there are lots of resources available. My favorite is SWIG but there are lots of options, including hand coding the conversion of your C/C++ -> LUA -> C/C++ code. Would recommend just focusing on getting the first part working first, get the interpreter embedded so that you can run a "hello, world!" script from Lua inside your app.
So going by your requirement of crossplatform use and dynamic linking, what you're probably looking for is an environment like QT which has QLibrary: https://stackoverflow.com/a/9675063/453673
But https://softwareengineering.stackexchange.com/questions/88685/why-arent-more-desktop-apps-written-with-qt
MingW is the open-source equivalent for Visual C++, so it can help you writing code for Windows (though if I had a choice, I'd directly use Visual C++). The way dll's are loaded in Windows is somewhat similar to the way they're loaded in Linux, so you'll be able to write code with #ifdef's to do conditional compilation. I've written one such program a couple of years back.
To load a shared library(always with .so as suffix) under Linux, you could use dlopen(), dlsym() and dlclose()

PlaySound() In C++ Doesn't Work

I've been trying to figure this out, and I just can't seem to.
When you include window.h at the top, there is supposed to be a PlaySound() function inside of it.
I added window.h but I keep on getting a "PlaySound was not declared in this scope" error.
I tried going into the project's build options and adding "-lwinmm" into the linker settings, but it still doesn't work.
I'm using Code::Blocks.
Anyone have a solution?
You need to #include both windows.h and mmsystem.h, in that order. This is noted in the community section of the documentation.
I assume you are coding on windows and you actually wanted the interface file called "Windows.h". Also make sure you are using the correct namespace, I'm not a windows programmer, but that's a start. I also don't know haw you are loading the file or wether you are using the win32 or .net frameworks. But then from the sounds of it you might not either.
If you're trying to use .net you can start here
http://msdn.microsoft.com/en-us/library/system.media.soundplayer
win 32 start here
http://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx
ah here it is winCE audio API
http://msdn.microsoft.com/en-us/library/aa909766.aspx

Can eclipse do auto-complete using external libraries like cocos2d?

I'm using Eclipse in linux. I have created a project using Cocos2D. It's a Java project, but im opening cpp and headers files to write native code.
Each time, i compile the native code with ./build_native.sh
I will like to know if eclipse could be configure to autocomplete functions in native code.
Example:
CCDirector::sharedDirector()->
Must show the options like getWinSize().
Some ideas? Thanks in advance.
I can't answer to the specifics of your question but in general I had this problem in C/C++ with iostream and STL libs. Even though everything would compile fine it wasn't supporting auto-complete. I ended up digging down into the supplied libraries to the root that held each .h file collection and added those to the directories path. Then I rebuilt the index and then auto-complete started working. So if cocos2d stores .h files in more than one location add each folder.
Have you installed the CDT? That give Eclipse C/C++ capabilities similar to what it already has for Java.