I followed the instructions but it seems my question got closed without even reading what my problem is
I have downloaded SNMP++ 3.4.9
library and copied it to my project's directory (where my project name is SNMP
)
So my directory looks like this:
>snmp++-3.4.9 [Folder]
>Include [Sub-Folder]
>Examples [Sub-Folder]
libsnmp.h
CMakeLists.txt
main.cpp
Inside main.cpp
I have pasted a code example that uses the library like this (first few lines):
#include <libsnmp.h>
#include "snmp_pp/snmp_pp.h"
...
When I try to run the code it won't work, I get:
[1/2] Building CXX object CMakeFiles/SNMP.dir/main.cpp.o
FAILED: CMakeFiles/SNMP.dir/main.cpp.o
.../XcodeDefault.xctoolchain/usr/bin/c++ -I/snmp++-3.4.9 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -std=gnu++14 -MD -MT CMakeFiles/SNMP.dir/main.cpp.o -MF CMakeFiles/SNMP.dir/main.cpp.o.d -o CMakeFiles/SNMP.dir/main.cpp.o -c /Users/john/CLionProjects/SNMP/main.cpp
/Users/john/CLionProjects/SNMP/main.cpp:28:10: fatal error: 'libsnmp.h' file not found
#include <libsnmp.h>
^~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
Someone suggested changing my CMakeLists.txt
file to something like this:
cmake_minimum_required(VERSION 3.21)
project(SNMP)
set(CMAKE_CXX_STANDARD 11)
include_directories("/snmp++-3.4.9")
add_executable(SNMP main.cpp)
But still same problem, how can I fix this?
Please Note: From a previous understanding I had with C++ I don't get it why they wrote:
#include <libsnmp.h>
and not:
#include "libsnmp.h"
As It's not a standard library, and changing every instance from <>
to ""
will take a very long time (and doesn't sound the right thing to do)
I'm using CLion and working on macOS.
Aucun commentaire:
Enregistrer un commentaire