Eclipse paho mqtt C++ as dependency in another project - c++

I have not much clue how c and c++ works at compile and runtime!
We are trying to use Eclipse Paho C++ library as a dependency in the project and messed up right now.
We have reffered to https://github.com/eclipse/paho.mqtt.cpp/tree/master/src/samples and used the same code in our project but we get this error.
error: 'mqtt' has not been declared class callback : public virtual mqtt::callback
We also have the following in place
Copied all the C and C++ libs(libmqttpp.so libpaho-mqtt3a.so.1.0 libpaho-mqtt3c.so.1 libmqttpp.so.0 libpaho-mqtt3as.so libpaho-mqtt3c.so.1.0 libmqttpp.so.0.1 libpaho-mqtt3as.so.1 libpaho-mqtt3cs.solibpaho-mqtt3a.so libpaho-mqtt3as.so.1.0 libpaho-mqtt3cs.so.1
libpaho-mqtt3a.so.1 libpaho-mqtt3c.so libpaho-mqtt3cs.so.1.0) to /usr/local/lib
Copied .h files(MQTTAsync.h MQTTClient.h MQTTClientPersistence.h) to /usr/local/include
Apart from above 2 steps, do I need to add anything to my project to resolve the problem or I am missing anything.

Finally, It worked after doing the following steps
Download 'C' zip from http://build.eclipse.org/technology/paho/
Copy lib files to /usr/lib/
Modified SConscript(alljoyn/gateway/gwagent/GatewatConnector/samples/) to extend LIBS - gwcnc_env.Prepend(LIBS = ['paho-mqtt3a', 'paho-mqtt3c', 'alljoyn_about', 'alljoyn_services_common', 'alljoyn_notification', 'alljoyn_config', 'alljoyn_gwconnector'])

Related

How to link a C project with a C++ static library(using opencv) in eclipse

I have created a c++ static library in eclipse which is using opencv.It is build fine and I want to include it in another c project in the same workspace.
Trying with
1)I have included library path in properties->c/c++ build->setting ->GCC C compiler ->Includes ->"path of project".
2)properties->c/c++ build->setting ->GCC C Linker-> Libraries ->Liraries(-i)->"Name of Lib"
3).properties->c/c++ build->setting ->GCC C Linker-> Libraries ->Liraries(-i)->"path of Lib"
But,this is not working while running the c project cannot find the static library functions giving error -"UNDEFINED REFERENCE TO THE FUNCTION"
Suggest a way to solve the problem.
Thanks in advance.
Got the answer.
These are the files needed to include
"${workspace_loc:/staticLibrary}"
MSDK/include
/IPP_Legacy/x64/include
Levmar/x64/include
/opencv/lib
opengl/x64/include/GL
Tesseract/x64/include/tesseract
freeGLUT/x64/include/GL
/ffmpeg/x64/include/libavcodec
compilers_and_libraries_2016.3.210/linux/ipp/include
compilers_and_libraries_2016.3.210/linux/mkl/include
compilers_and_libraries_2016.3.210/linux/tbb/include
compilers_and_libraries_2016.3.210/linux/daal/include
After these inclusion I faced a error of
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
for which I got help from the link
http://i0.wp.com/omtlab.com/wp-content/uploads/2013/07/4.png
now the program is working all fine
Thank you

Using C++ inside an iOS CocoaPod

I am building a private cocoapod for iOS, and am running into issues with some C++ code. The project builds fine in XCode, but when I attempt to run pod lib lint MyProjectName.podspec I get the following error:
- ERROR | xcodebuild: /path/to/aheader.h:2:10: error: 'string' file not found
The header has the following first line:
#include <string>
Searching for possible solutions, I added the following to podspec (based on CocoaPods: Linking with C++ symbols defined in libPods.a)
s.source_files = "MyProjectName/**/*.{swift,c,m,h,mm,cpp,plist}"
s.library = 'c++'
s.xcconfig = {
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11',
'CLANG_CXX_LIBRARY' => 'libc++'
}
But it made no difference to the error. Another suggestion I saw was to "use a wrapper", but this piece of code (which is 3rd-party IP that I can not port to Objective C) is already using a wrapper.
How can I build the pod successfully by mixing both Objective C and C++ along with Swift? Any (non-null) pointers would be appreciated.
I had to simply renamed the C++ header extension to .hpp, so it was not included by default in the source_files filter. This resolved the issue, as the wrapper was including the header. Posting this in case someone else runs into the same issue.
Update: Nope, it just lets the app build, but using the pod still doesn't work.
Try explicitly adding stdc++ in the linker options.
s.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '-l"stdc++"'
}

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...

C++; eclipse linker error

So working on getting my eclipse IDE going so I can develop my arduino uno in eclipse.
My C++ is weak so this is probably a nube error on my part.
I have a blink program that looks for an arduino library I compiled from the arduino IDE's library.
My code points to the header file and my code find it fine; meaning I can click on:
#include <arduino.h>
and go view the header
this: "C:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a"
is a valid path... but I get the following error:
>****** Build of configuration Debug for project project1 ****
>make all
>Building target: project1.elf
>Invoking: AVR C++ Linker
>avr-g++ -Wl,-Map,project1.map,--cref -L"C:\programs\arduino->1.0\hardware\arduino\cores\328p_lib" -mmcu=atmega328p -o "project1.elf" ./code/code1.o >-l"C:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a"
>c:/programs/winavr/bin/../lib/gcc/avr/4.3.3/../../../../avr/bin/ld.exe: cannot find ->lC:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a
>make: *** [project1.elf] Error 1
>**** Build Finished ******
Well after wasting 2 days or so of fun time I finally found the problem.
http://sourceforge.net/projects/avr-eclipse/forums/forum/664382/topic/4640554
When adding the static library to the linker you have to remove the lib prefix and the .a suffix. not sure what that is about.
Right click on the project>Click on C/C++ BUild> Settings > GCC C++ Linker> Libraries
Click the first icon Add> Add the library name ( without the .a suffix, the suffix will be added automatically)
This will ensure that the library is added to the project.
If the library is part of another project >Go to GCC C Compiler> directories >Add the directory
This will ensure that the library is there for getting the compilation done.

Debugging SFML Project in Xcode - Install to Blame?

I followed the instructions to set up SFML here. When I check my /Library/Frameworks folder, all the SFML stuff seems to be there. However, when I check out a project my group is working on using SFML, and when I build, I get a ton of errors. These errors do not exist for my other group members. I think (some of) my errors are caused by SFML not recognizing sf::Input as a type.
Here is my code for one of the header classes in my project:
#pragma once
#include "Mover.h"
class InputMover : public Mover
{
public:
InputMover(const sf::Input* pInput);
//error here - expected unqualified-id before * token
protected:
const sf::Input* m_pInput;
//error here - ISO C++ forbids declaration of Input with no type
};
The parts without errors have been taken out. What do you think the problem is?
EDIT, SOLVED:
The problem was that I installed SFML with makefiles before I just did a copy-install. Some files were conflicting. I tracked down the installed files and deleted them. This seemed to fix the problem.
To use the SFML classes you need to include their definitions.
Add #include <SFML/Window/Input.hpp> to the top of your file.
Also note that to use SFML you must also link to the CoreFoundation, Cocoa and OpenGL frameworks, as well as to libfreetype.