how to use aidl-cpp to generate .aidl to c++ code - c++

What I need: compile .aidl file to c++ code
What I found: Generating C++ Binder Interfaces with aidl-cpp
AIDL compiler for C++ on Linux Desktop
3.What I did:I had clone the "aidl-cpp" on the second link,after viewing the many files in the project,I was missing.
Some doubt here:
Can I compile this project and use the target to compile my
project?If yes,I need the whole android platformtsource code in my
system path?Because I try to compile one single file main_java.cpp
with g++ commandline , and it returns some "android-base" libs
cannot find.
Or I can write my own cpp file to implement the interfaces defined
in my .aidl files imitate the "aidl-cpp" project.This way I haven't
tried.
What's the right way to meet my need?

You can just use aidl of android sdk build-tools after 29.0.0.
aidl --lang=ndk <input.aidl>

Related

Using a function defined in a DLL from C++ code

I built Qt from source (dlls) and am trying to build an application that uses the Qt dlls. I don't have a lot of experience with C++ so I'm running into what I'm sure is a very basic issue.
My builds are failing on the includes with errors like so:
Fatal error: QNetworkProxy: No such file or directory
Here is the g++ command I am using (I also used -L to add the correct folder to the lib path, but that also didn't work):
g++ -l..\..\wkqt\bin\QtCore4.dll -l..\..\wkqt\bin\QtNetwork4.dll -l..\..\wkqt\bin\QtWebKit4.dll -I..\include -Ishared -Ipdf -Ilib -Iimage -o ..\bin\wkhtmltopdf.exe pdf\*.cc lib\*.cc image\*.cc shared\*.cc
I tried in Visual Studio as well (assuming it wouldn't build, but I wanted to see if I could at least include the Qt dlls from there properly) and I am getting the same errors. Am I doing something wrong with the way I am compiling with g++? If I am linking with the Dlls properly then what is the proper way to use Qt functions from my code?
To clarify, I am not looking for how to properly use Qt. My question is: what is the proper way to use functions defined in any Dll from native C++ code? I apologize if this is a very basic question, but I'm unable to find a clear answer on Google and I don't have any experience with C++ and including third party libraries for use from C++ code.
DLLs can be used by dynamicly loading them and calling their used functions.
to call the exposed functions first define their syntax in the begining
suppose function is syntax is
BOOL MyFunction(int a,char* pszString)
then define syntax
#typedef BOOL (WINAPI *PMYFUNCTION)(int a,char* pszString)
then make object
PMYFUNCTION pfnMyFunction;
and get valid pointer by calling GetProcaddress after loadlibrarycall
HMODULE hlib= Loadlibrary("c:\\Mylib.dll");
if(hlib)
{ pfnMyFunction = (PMYFUNCTION)Getprocaddress(hlib,"MyFunction"); }
Hope this helps...

How to use SWIG for D from C++ on Windows?

I want to use LEAP Motion in D.
Therefore It doesn't have C library and It has only C++ library.
I tried SWIG 2.0.9 below command.
swig -c++ -d -d2 leap.i
This command output Leap.d, Leap_im.d, Leap_wrap.cxx, Leap_wrap.h.
However, I don't know how to use to wrapper in D and I can't find how to use the wrapper.
Link error displays to use it intact.
How use these wrapper in D2?
And can I use without Leap.cpp (source of Leap.dll)?
Update:
Thanks two answers. and sorry for reply late because of busy.
Say first conclusion I could build Leap sample code on Win64 by following the steps below.
Output wrappers by above command.
Create x64 DLL with VC2010 from Leap_wrap.cxx, Leap_wrap.h, and import Leap.lib(x64).
Compile Leap.d and Leap_im.d with dmd -c.
Build LeapTest.d with Leap.obj and Leap_im.obj
all command is below.
swig -c++ -d -d2 leap.i
dmd -c Leap.d Leap_im.d -m64
dmd LeapTest.d Leap.obj Leap_im.obj -m64
execute LeapTest.exe (require x64 Leap.dll and Leap_wrap.dll)
I could run Leap Program.
But program crach onFrame event callback.
I'll try again on x86 and investigate the causes.
Few helpful links (some information may be outdated):
http://klickverbot.at/blog/2010/11/announcing-d-support-in-swig/
http://www.swig.org/Doc2.0/D.html
http://www.swig.org/tutorial.html
I have never used SWIG personally but my guess based on general knowledge about SWIG:
Leap_wrap.cxx is C++ source file that wraps calls to C++ functions from target library in extern(C) calls
Leap_wrap.h is header file with all extern(C) wrappers listed
Leap_im.d is D module based on Leap_wrap.h with same extern(C) function listed
Leap.d is D module that uses Leap_im.d as an implementation and reproduces API similar to original C++ one.
So in your D code you want to import Leap.d module. Than compile Leap_wrap.cxx to an object file with your C++ compiler and provide D object files, Leap_wrap.o and target library at linking stage. That should do the trick.
P.S. Leap.cpp source should not be needed. All stuff links directly from Leap_wrap.cxx to target library binary.
Go to IRC, either FreeNode, or OFTC, channel #D. In order to help you, we have to see what is in those files. My first guess is that you have to compile both D files, and the C++ file into object files, and link them together. I suppose SWIG is going to flatten the C++ API into bunch of C functions, and that is probably what Leap_wrap.cxx does.
If the LEAP API is not complex (ie. just bunch of simple C++ classes), it may be possible to directly interface with it. Read more about it here: http://dlang.org/cpp_interface.html .

Is it possible to symbolicate C++ code?

I have been running into trouble recently trying to symbolicate a crash log of an iOS app. For some reason the UUID of the dSYM was not indexed in Spotlight. After some manual search and a healthy dose of command line incantations, I managed to symbolicate partially the crash log.
At first I thought the dSYM might be incomplete or something like that, but then I realized that the method calls missing were the ones occurring in C++ code: this project is an Objective-C app that calls into C++ libraries (via Objective-C++) which call back to Objective-C code (again, via Objective-C++ code). The calls that I'm missing are, specifically, the ones that happen in C++ land.
So, my question is: is there some way that the symbolication process can resolve the function calls of C++ code? Which special options do I need to set, if any?
One useful program that comes with the apple sdk is atos (address to symbol). Basically, here's what you want to do:
atos -o myExecutable -arch armv7 0x(address here)
It should print out the name of the symbol at that address.
I'm not well versed in Objective-C, but I'd make sure that the C++ code is being compiled with symbols. Particularly, did you make sure to include -rdynamic and/or -g when compiling the C++ code?
try
dwarfdump --lookup=0xYOUR_ADRESS YOUR_DSYM_FILE
you will have to look up each adress manually ( or write a script to do this ) but if the symbols are ok ( your dSym file is bigger than say 20MB) this will do the job .

Set Up iOS project to use eigen

I'm trying to set up an iOS project to compile a c++ library called Eigen for Linear Algebra maths.
I begin following the instructions of the Question mentioned in:
How to compile Eigen in iPhone
But there are still some kind of things I could not figure out.
User Stafan said to set the right compiler flags (-mfpu=neon -mfloat-abi=softfp). Where do I set those flags? I already found out to set flags for a single file like in http://meandmark.com/blog/2011/10/xcode-4-setting-compiler-flags-for-a-single-file/. But for what files do I need to set this flags? Especially the c++ files from the Eigen library do not appear here.
User Blukee said that he used armv7 optimized arch in build setting. In build settings I see in the Architectures category a green field saying Standard(armv7) is that what right?
I just created a ,,singleViewApplication'' and wanted to use the c++ files in an new Objective C class called MathLibary. Because some guys said that it is possible to mix up Objective C and C++ if I name the class MathLibary.hh and MathLibary.mm.
The class looks like
#import "MathLibary.hh"
#define EIGEN_DONT_VECTORIZE
#import "SVD.h"
#implementation MathLibary
#end
When I try to run the App the build fails an the compiler gives out some errors like:
In line 47 in SVD.h file, which is:
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
The error is Expected a qualified name after 'type name'
For me it sounds as that the compiler tries to compile the SVD.h as objective c file but is c++.
How do I change the compiler to compile both objective c files for the user interface and the c++ files from the library
I hope that somebody is able to help me, thanks a lot.
If you want to mix ObjC and C++, did you make sure to rename your file to have a ".mm" suffix? :)

Help: VS2005 Compile *.m file

all
I have test.m( matlab source code) file which implement A() function; and main.cpp file (will call A() ).
as you know ,we may do like the following steps:
use matlab to compile test.m (mcc -) ,will generate : test.dll, test.ctf,test.h .
copy the test.dll and test.ctf ,test.h file to VS2005 project. in main.cpp, call A() in test.dll.
But,when i release the programe,i will also pack the test.dll together.
And another way, can i using the VS2005 to compile both test.m and main.cpp which will only generate main.dll,main.ctf,main.h..( i will only release main.dll,main.ctf,main.h,).
this means, i compile the test.m into main.cpp.
And i have tried this way, in VS2005 ---> Build Events--> pre-Build Event-->command line: mcc C -w lib:test test.m
and it will generate the mid-file test.ctf(only test.ctf,no test.dll).But i don't know how to compile test.ctf into main.cpp ?
could anyone help me ?
thanks.
You can do it the other way around and add your main.cpp to the matlab build process: I don't know the exact syntax, but you can add your main.cpp to mcc/mbuild, and it will add it to the dll for you. When using deploytool in gui mode, just drag c/c++ files to the resources area and they get compiled into the dll. So you'll have one dll only containing both m code and your own c++ code.
Another option, using the above strategy: first try the above, and look at the output of deploytool: it will show you the commands used. First it invokes mcc, then mbuild which in turn calls cl (the MS compiler). Use the exact command used to invoke mcc as a pre-build event, and then add that output files to cl in the same way mbuild does it (you can also see in the output how it does that). This way you can use VS to build a single dll anyway, just mimick what the matlab build process does.
Still I'm not sure how this is beneficial over distributing the two seperately. Also don't forget you have to distribute the entire MCR with it else your clients won't be able to run any code using the dll.