External C++ source files in android studio? - c++

Here is the drill. I have a cross-platform project written mostly in C++ (more on this later) that runs on windows, android and ios.
Is there any way in which android studio can be configured to have a custom directory that contains all the native C++ code ? By custom, I mean external to the main folder in which the android studio project resides in.
I'm guessing you can see where I'm getting at... I have a cross-platform project that can be opened from 3 different IDE's... visual studio, android studio and xcode and I want to be able to write / edit / compile the code from all of them.
Let's say I have the following main hierarchy:
projectDir
src (C++ source files .cpp)
include (C++ headers .h)
_visualStudio (visual studio project)
_xcode (xcode project)
_androidStudio (android studio project)
assets (resources .png etc)
others...
This is what I want to achieve, but I am unable to figure out how can I configure an android studio project to be able to accept external source files, but most importantly to be able to see and edit them from the android studio IDE. Basically I want to tell android studio... "Look, this is the path for the native files, treat them as if they belong to the project".
I know this is possible from visual studio and from xcode because I already did that, but up until now I used my own build system for android and I had no need for android studio. Is there any way to achieve this ? Perhaps some kind of symbolic folder links ?
The thing is I want to keep only a single copy of my shared resources (src, include and assets should only be in one place, but should be available for android studio as well).
So far the only solution is to keep them inside android studio project directory, and change visual studio paths to look for them there, but I find this very nonprofessional.
EDIT:
Is there any addFileToProject (as in visual studio) in android studio in which the file can be outside the project ?

After a bit of more digging I found that it is actually possible.
You just have to create a directory junction like this (inside app/src/main/cpp where the files would normally be).
mklink \J linkName linkDestination(can be outside the project)
Android studio will be able to see the containing folder as it's own (it sees it as a link, but you can double click it to expand the contents). You can also edit source files inside it with the only mention that you have to add these files within CMakeLists.txt or whatever build file you are using in order to have intellisense (you get a sync warning from android studio if the files aren't referenced anywhere in the build files).
Later edit... if you are using junctions for Java / Kotlin files in an android studio project, make sure to set the source sets through the junctions as well... in order to avoid visual errors like 'duplicated class'.

Related

make visual studio add all necessary when building release

So I am working on an example project that displays video from a network stream.
The project is in C++.
After building the project in release, and trying to run the project on a different computer, I get errors on missing DLL files.
These DLL files are located within the installation location of Visual studio.
one example is msvcp140d.dll.
After copying all the missing files, I get a generic error with no specific file.
So:
Is there a way to tell visual studio to add all relevant files when building the project?

How to move some files under version control from one project to another in Visual Studio 2015?

I use c++, mercurial as VCS and IDE - Visual Studio 2015. Sometimes I need to extract some files from project to separate project (in the same solution). Now for that I have to:
create new project in the same solution
use mercurial "rename" for all files I need to move
remove files from source project manually via Visual Studio
add files to destination project manually via Visual Studio
fix includes in these files
maybe something else (change namespace, etc.)
It would be nice making items 2, 3 and 4 at once (and somehow automatically). I Can't find anything suitable so I will be very grateful for any advice about it (maybe some tools, scripts, Visual Studio extensions or something else).

Qt - Visual Studio - Work with projects on multiple computers

I work with the same Visual Studio projects on multiple computers (work/home) using Dropbox to sync between the two. Because VS creates some extra large files, I used to remove the following before uploading to Dropbox:
Files = .pdb, sdf, .ilk .exe .tmp
Folders = ipch/, Release/, Debug/, GeneratedFiles/
Everything worked fine in the past, however, some problems have now risen.
I receive the following errors:
Moc'ing CodeInterface.h...
1> The system cannot find the path specified.
1> Moc'ing ThreadWorker.h...
1> The system cannot find the path specified.
1> Rcc'ing StreamAnalyser.qrc...
1> The system cannot find the path specified.
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 3.
So, I think I may have to create a new Visual Studio project and import the classes manually. So my question are:
Best practices for working with projects on different computers?
What files can be deleted (for uploading to Dropbox)?
Does Visual Studio have some sort of 'global settings' (or something similar to 'workspace' used with Eclipse)? How do I set these settings to prevent trouble when working on different computers?
Thanks!
I am not familiar with dropbox so I can't speak for what you do currently
What I like to do is to use a distributed versioning system (I use git) to look after the source code only. I use a .gitignore file to not version any object code and visual studio project files and the like. I can then clone these projects (with their versioning) easily across to any computer I like - including test branches that I might idly play with when coming home on the train on my laptop.
In my experience visual studio project files are a pain because different versions do not play nicely with eachother (1 computer has vs2005 and another has vs2008). To overcome this problem I like to use cmake as my build system (I include these in my git repository too). Cmake is a 'meta-build system', in that it generates the visual studio, or eclipse, or autotools make files for you, and then you do the native build in VS or Eclipse or with make.
Using these two packages together means that you can copy properly versioned controlled source code between any computer (including linux, mac and windows) and then build the source code natively on that computer, using whatever IDE you have installed on that computer.
"moc" is a Qt executable that pre-processes .h files. It's invoked by the MSVS build system. However, if it would be missing, you'd get the "The system cannot find the path specified." error after "Moc'ing CodeInterface.h".
My bet therefore is that MSVS can't find your Qt implementation. I'm not entirely surprised; the Qt4 build system and its integration with MSVS didn't strike me as very robust ir reliable when I tried to install it recently.
I would recomend you use svn with anksvn. Subversion is built to manage working on diffrent computers and has the added bonus of version controll.
In your case, you may delete files but not directories, i.e. GeneratedFiles\Debug and \Release should stay. If you look onto your h files, they do moc-ing and uic-ing as custom build step, and there is no path checking code in that events.
"$(QTDIR)\bin\moc.exe" -DQT_NO_QT_INCLUDE_WARN -DUNICODE -DWIN32 -DQT_THREAD_SUPPORT -DQT_CORE_LIB -DQT_NETWORK_LIB -DJSBRIDGEAPI_LIB -D_WINDLL -I".\GeneratedFiles\." -I"$(QTDIR)\include\." -I".\GeneratedFiles\$(ConfigurationName)\." -I".\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtNetwork\." -I"$(QTDIR)\include\QtWebKit\." ".\apisignalemitter.h" -o ".\GeneratedFiles\$(ConfigurationName)\moc_apisignalemitter.cpp"
So - adding dirs .\GeneratedFiles\$(ConfigurationName)\ may solve your problem.
Also, check if $(QTDIR) defined.
UPD - make sure you have QT installed on both machines in some place
I'm usually using SVN for version control and a qmake pro file for project settings. You can use qmake to create a Visual Studio project file from the pro file and work with Visual Studio, or create Makefiles and other project files on Windows, Linux and Mac, so it's a quite portable solution.

Making a GCC based Project Build and Run under Visual Studio 2010

I have been trying to port my C++ based mass data transport protocol project into visual studio 2010 with no success :(
The code I have been working on is fully compatible with Win based systems..well this is what my mentor also says :) But I have not been able to make the project build and run using my existing *.h & *.cpp files under VS 2010.
The Project basically is a API under which i have 4 separate applications. The hierarchy would be:
SRC FOLDER- all the *.h and respective *.cpp files
APP FOLDER- 4 applications (the API / library and some *.h files to be available before linking such as the final dll file under SRC folder & the main header file under APP folder)
I do also have a makefile as when the project was developed on Linux platform but I have no idea how to implement the same on Visual Studio 2010
FYI: VS 2010 on compiling reports that there are missing header files such as <cstdlib>, <unistd> but my best bet is this is not the real prob. but the prob. lies in the way I make the project build itself. I don't know should I go with making a dynamic dll project for the main library and then make the 4 empty c++ projects inside that for the 4 respective applications..?
Cheers,
echo9
I would recommend that you parse the data that you need from the working .mak file that you used previously. Create an empty project & sln, then add the contents of the "src" by using "add->existing files" in the file menu.
At that point open up the project configuration settings and go through the C++ and linker settings one by one. At each step have a look at the linux .mak file and see that you are choosing equivalent options and path settings. In particular make sure that you add all of the necessary include paths to where your .h files are.
That's what I would do anyways... same process as porting forwards old MSVC4 .mak projects to a modern version.

Cross-platform svn management (Makefiles & Visual Studio)

I'm working on a little game called freegemas, it's an open source version of the classic Bejeweled written in C++ and using gosu as the graphic API. I've been developing it under Ubuntu Linux as usual, but the other day I wanted to give it a try and I compiled it on Windows using Visual Studio 2005 (which I had never used before). The program worked flawlessly.
To compile it on Windows I manually copied all the source and header files to a new project on MSVC, but I would like to adapt the SVN so I don't have to recreate the project every time I want to compile it.
Therefore, the question would be: What's the best way of organizing the svn so I can have, on the one hand, a Makefile to compile the project in Linux, and, on the other side, the MSVC project's files? Right now I've got a simple folder called trunk with all header, source and resource files on it.
I've never used Visual Studio before, so I don't know which files are the most important either. Maybe some of those files are auto-generated and do not need to be svn-versioned.
Thanks in advance.
You could just keep the project files in a seperate directory "winbuild" or similar. Still, to maintain them would require manual interaction (ie adding every new file manually). The only files you would need to upload to svn are the *.vcproj (for MSVC 2005/2008) and *.vcxproj (MSVC 2010).
Alternatively, you could opt for a cross-platform solution like CMake, which could generate makefiles and Visual Studio project files from a common CMakeLists.txt, which is the only "project file" that would have to be maintained (instead of your makefile). Especially for a simple (?) project like yours (some headers+sources). There would be no need to include any makefiles or vcproj files at all, just the CMakelists.txt file would suffice.
There are others like CMake (SCons, boost.jam, jam, premake, etc.)
It should be feasable, but requires some testing and trial-and-error.