aws / aws-iot-device-sdk-cpp

SDK for connecting to AWS IoT from a device using C++
http://aws-iot-device-sdk-cpp-docs.s3-website-us-east-1.amazonaws.com
Apache License 2.0
122 stars 111 forks source link

Sample application include in aws static lib #113

Closed nagarajec closed 4 years ago

nagarajec commented 6 years ago

Hi All, I have below questions:

  1. I have added addFunction() (for testing purpose) method in PubSub.cpp under samples/pubsub/pubsub.cpp file and complied and build the static library using makefile, the lib in pubsub/archive/ libaws-iot-sdk-cpp.a should contain the changes of pubsub.cpp correct?
  2. I have another application uses this static lib and I am trying to call method addFunction() in static lib (libaws-iot-sdk-cpp.a) but I am getting below errors. So How can I call anyfunctions in sdk library from third party applications?

./main_body_pub_test.cpp:16:11: error: ‘addFunction’ is not a member of ‘awsiotsdk::samples’ int a = awsiotsdk::samples::addFunction(4,6);

main_body_pubtest.cpp: #include

include

include "PubSub.hpp"

int main(int argc, char **argv) { int a = awsiotsdk::samples::addFunction(4,6); printf("Result :%i\n",a); }_

PubSub.hpp: #pragma once namespace awsiotsdk { namespace samples { class PubSub { public: int addFunction(int a, int b); }; } }

MakeFile: _CXX=g++ SYS_HEADER_DIR = /usr/local/include/ APP_DIR = ./ APP_NAME = main_body_pub_test APP_C_FILES = $(APP_DIR)$(APP_NAME).cpp APP_H_FILES = $(APP_DIR)PubSub.hpp $(SYS_HEADER_DIR)/curl/curl.h STATIC_LIBS_DIR = ./ STATIC_LIBS = ./libaws-iot-sdk-cpp.a -lcurl -lmbedtls -lmbedcrypto -lmbedx509 SOURCES = $(APP_C_FILES) $(APP_H_FILES) $(STATIC_LIBS) $(APP_NAME):$(SOURCES) $(CXX) -std=c++11 -o $@ $(APP_C_FILES) $(STATICLIBS)

nagarajec commented 6 years ago

@vareddy could you please clarify? thoughts?

JonathanHenson commented 6 years ago

Could you try?

int main(int argc, char **argv) {
    awsiotsdk::samples::PubSub pubSub;
    int a = pubSub.addFunction(4, 6);
    printf("Result :%i\n",a);
}
swatinair1234 commented 4 years ago

Hi Nagaraj , I am working on the PubSub in samples. I havent created any separate main.cpp. I am trying the example in PubSub.cpp. I am trying to build it . But its giving me errors like OpenSSLConnection.hpp is not found inspite of adding the include files.This is my task.json file { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "taskName": "build", "command": "g++", "args": [ "-g", "PubSub.cpp", "libaws-iot-sdk-cpp.a"

        ],
        "problemMatcher": [
            "$gcc"
        ]
    }
]

} Please let me know if i have to add any other static libs or so .Thanks in advance I have included the header files in c_cpp_properties.json.Its as below.I have build the SDK using CMAkE and created the static library .

{ "configurations": [ { "name": "Linux", "includePath": [ "/home/mahathi/Dev/aws-iot-device-sdk-cpp/include", "/home/mahathi/Dev/aws-iot-device-sdk-cpp/build/third_party/rapidjson/src/include/rapidjson", "/home/mahathi/Dev/aws-iot-device-sdk-cpp/include", "/home/mahathi/Dev/aws-iot-device-sdk-cpp/common", "/home/mahathi/Dev/aws-iot-device-sdk-cpp/build/third_party/rapidjson/src/include", "/home/mahathi/Dev/aws-iot-device-sdk-cpp/network/OpenSSL" ], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "version": 4

github-actions[bot] commented 4 years ago

Greetings! Sorry to say but this is a very old issue that is probably not getting as much attention as it deserves. We encourage you to try V2 and if you find that this is still a problem, please feel free to open a new issue there.