本文介绍了在我的C ++ OpenFrameworks项目中对wpa_ctrl函数的未定义引用.需要帮助集成此C库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用菜单选项来连接到使用OpenFrameworks构建的C ++应用程序中的wifi.我想使用 wpa_ctrl 库,但我无法对其进行编译.

I'm working on a menu option to connect to wifi in my C++ application that is build using OpenFrameworks. I want to use the wpa_ctrl library but I can't get it to compile.

代码段:

NetworkWrapper.h:

NetworkWrapper.h:

#ifndef NETWORKWRAPPER_H_
#define NETWORKWRAPPER_H_

class NetworkWrapper {
public:
     NetworkWrapper():
private:
     struct wpa_ctrl* m_ctrl;
};
#endif

NetworkWrapper.cpp:

NetworkWrapper.cpp:

#include "NetworkWrapper.h"
extern "C" {
     #include "wpa_ctrl.h"
}

NetworkWrapper::NetworkWrapper() {
     m_ctrl = wpa_ctrl_open("wlan0");
}

错误:

***/NetworkWrapper.cpp:7: undefined reference to `wpa_ctrl_open'
collect2: error: ld returned 1 exit status

我尝试抛出include并使用和不使用extern"C",但是看到wpa_ctrl.h也包含在extern"C"标记中没有什么区别,尽管使用#ifdef __cplusplus(已定义) ,我再次检查了.)

I've tried throwing around the include and using and not using extern "C" but it makes no difference seeing as wpa_ctrl.h is also enclosed in the extern "C" tag, albeit with #ifdef __cplusplus (which is defined, I double checked).

我现在几乎没有主意了.我应该注意,我尝试将wpa_ctrl.c包含在外部"C"标记中,据我所知,该标记不应该编译(?).这也给出了完全相同的结果.这导致我手动编译wpa_ctrl库并将其复制到obj目录,但是再次出现:同样的结果.

I'm pretty much out of ideas now. I should note that I tried enclosing wpa_ctrl.c in the extern "C" tags, which to my knowledge shouldn't compile(?). Which also gave the exact same result. This led me to manually compiling the wpa_ctrl library and copying to the obj directory but again: same result.

感谢您抽出宝贵的时间阅读我的问题,希望能对您有所帮助!

Thank you for taking the time to read my question, hope you can help!

*编辑* 根据请求,我的链接选项(我将其修剪了一点):

* EDIT *As per request my linking options (I trimmed it down a bit):

g ++ -o bin/application_debug obj/linux64/Debug/src/main.o [...] obj/linux64/Debug/src/libs/wpa_ctrl.o [. ..] obj/linux64/Debug/src/common/NetworkWrapper.o [...] -Wl,-rpath =./libs:./bin/libs -Wl, -按需-Wl,-gc-sections -Wl,-rpath =./libs -liw -L ../../../libs/fmodex/lib/linux64/-lfmodex -L ./bin /libs -lSDL -lSDL_mixer -lcurl ../../../libs/glfw/lib/linux64/libglfw3.a ../../../libs/kiss/lib/linux64/libkiss.a .. /../../libs/rtAudio/lib/linux64/libRtAudio.a ../../../libs/tess2/lib/linux64/libtess2.a ../../../libs/poco /lib/linux64/libPocoNet.a ../../../libs/poco/lib/linux64/libPocoXML.a ../../../libs/poco/lib/linux64/libPocoUtil.a .. /../../libs/poco/lib/linux64/libPocoFoundation.a ../../../libs/poco/lib/linux64/libPocoNetSSL.a ../../../libs/poco /lib/linux64/libPocoNet.a ../../../libs/poco/lib/linux64/libPocoCrypto.a ../../../libs/poco/lib/linux64/libPocoUtil.a .. /../../libs/poco/lib/linux64/libPocoXML.a ../../../libs/poco/lib/linux64/libPocoFoundation.a -L/usr/lib64 -lz -lgstapp-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstreamer-0.10 -lgmodule-2.0 -pthread -lgthread-2.0 -pthread -lxml2 -ludev -lsndfile -lopenal -lssl- lcrypto -lpulse-simple -lpulse -lasound -lGLEW -lGLU -lGL -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0- lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lmpg123 -lglut -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl -lpthread -lfreeimage

g++ -o bin/application_debug obj/linux64/Debug/src/main.o [...] obj/linux64/Debug/src/libs/wpa_ctrl.o [...] obj/linux64/Debug/src/common/NetworkWrapper.o [...] -Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -Wl,-rpath=./libs -liw -L../../../libs/fmodex/lib/linux64/ -lfmodex -L ./bin/libs -lSDL -lSDL_mixer -lcurl ../../../libs/glfw/lib/linux64/libglfw3.a ../../../libs/kiss/lib/linux64/libkiss.a ../../../libs/rtAudio/lib/linux64/libRtAudio.a ../../../libs/tess2/lib/linux64/libtess2.a ../../../libs/poco/lib/linux64/libPocoNet.a ../../../libs/poco/lib/linux64/libPocoXML.a ../../../libs/poco/lib/linux64/libPocoUtil.a ../../../libs/poco/lib/linux64/libPocoFoundation.a ../../../libs/poco/lib/linux64/libPocoNetSSL.a ../../../libs/poco/lib/linux64/libPocoNet.a ../../../libs/poco/lib/linux64/libPocoCrypto.a ../../../libs/poco/lib/linux64/libPocoUtil.a ../../../libs/poco/lib/linux64/libPocoXML.a ../../../libs/poco/lib/linux64/libPocoFoundation.a -L/usr/lib64 -lz -lgstapp-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstreamer-0.10 -lgmodule-2.0 -pthread -lgthread-2.0 -pthread -lxml2 -ludev -lsndfile -lopenal -lssl -lcrypto -lpulse-simple -lpulse -lasound -lGLEW -lGLU -lGL -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lmpg123 -lglut -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl -lpthread -lfreeimage

推荐答案

所以我终于发现我做错了什么.对于未来的访客:

So I finally found what I was doing wrong. For future visitors:

我需要在我的makefile中添加以下定义:

I needed to add the following defines in my makefile:

-D CONFIG_CTRL_IFACE -D CONFIG_CTRL_IFACE_UNIX

这篇关于在我的C ++ OpenFrameworks项目中对wpa_ctrl函数的未定义引用.需要帮助集成此C库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 02:36