试图让getch()努力捕获按键.
#include <curses.h>
...
...
WINDOW *w;
char f;
w = initscr();
timeout(3000);
f = getch();
endwin();
Run Code Online (Sandbox Code Playgroud)
给我以下错误: -
undefined reference to `wgetch'
undefined reference to `stdscr'
Run Code Online (Sandbox Code Playgroud) 我试图移植一个应用程序来驱动一个使用ftdi2332h芯片的设备从Windows到Linux.我按照这些说明在ubuntu 10.04系统上安装了libftd2xx库.
当我尝试编译任何示例程序时,我收到以下错误:
/usr/local/lib/libftd2xx.so: undefined reference to `memcpy@GLIBC_2.14'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
有关如何解决这个问题的指导原则?
我在编译使用glfw3库的程序时遇到问题.
我在尝试使用make编译时得到未定义引用的错误列表但是我的类被编译成.o文件,只创建了最终的可执行文件.
标准输出:
g++ -Wall -g -c main.cpp -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi
g++ -Wall -g -c error.cpp -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi
g++ -Wall -g -c sWindow.cpp -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi
g++ -Wall -g -o ecl main.o error.o sWindow.o -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi
Run Code Online (Sandbox Code Playgroud)
标准错误:
/usr/local/lib/libglfw3.a(context.c.o): In function `parseGLVersion':
context.c:(.text+0x53): undefined reference to `glGetString'
/usr/local/lib/libglfw3.a(context.c.o): In function `_glfwRefreshContextAttribs':
context.c:(.text+0x907): undefined reference to `glGetIntegerv'
context.c:(.text+0x98a): undefined reference …Run Code Online (Sandbox Code Playgroud) 我正在使用信号量,但我一直遇到未定义的参考警告,从而导致我的代码无法工作.我从文本中提取了示例代码,但是他们遇到了一些语法问题,所以我去了POSIX的信号量教程并改变了它们的语法,结果我现在得到了这些引用错误.
我可能只是忽略了一些东西,但我找不到它.
错误:
Producers_Consumers.c:52: warning: return type of ‘main’ is not ‘int’
/tmp/cceeOM6F.o: In function `producer':
Producers_Consumers.c:(.text+0x1e): undefined reference to `sem_init'
Producers_Consumers.c:(.text+0x3a): undefined reference to `sem_init'
Producers_Consumers.c:(.text+0x46): undefined reference to `sem_wait'
Producers_Consumers.c:(.text+0x52): undefined reference to `sem_wait'
Producers_Consumers.c:(.text+0x5e): undefined reference to `sem_post'
Producers_Consumers.c:(.text+0x6a): undefined reference to `sem_post'
/tmp/cceeOM6F.o: In function `consumer':
Producers_Consumers.c:(.text+0x7e): undefined reference to `sem_wait'
Producers_Consumers.c:(.text+0x8a): undefined reference to `sem_wait'
Producers_Consumers.c:(.text+0x96): undefined reference to `sem_post'
Producers_Consumers.c:(.text+0xa2): undefined reference to `sem_post'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我有什么(由于我从旧方法中评论出来的方式,它可能看起来有点难看)我也知道我的添加方法不起作用,但是当我修复语法问题时我会做到这一点:
#include <stdio.h>
#include …Run Code Online (Sandbox Code Playgroud) 使用MINGW,我试图将我的C代码链接到执行一些OLE操作的静态C++库:
mingw32-gcc main.o resources.o -o mbcom.exe -L../../Lib/Iup -liup -liupole -lole32 -lcomctl32 -lstdc++ -mwindows
Run Code Online (Sandbox Code Playgroud)
不幸的是,我得到了这个:
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0x341): undefined reference to `IID_IOleControl'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0x9b0): undefined reference to `IID_IViewObject2'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xcb5): undefined reference to `IID_IUnknown'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xce8): undefined reference to `IID_IPersistStorage'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xd1b): undefined reference to `IID_IOleObject'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xd9d): undefined reference to `IID_IUnknown'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xdbf): undefined reference to `IID_IOleClientSite'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xde1): undefined reference to `IID_IOleWindow'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xe03): undefined reference to `IID_IOleControlSite'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xe25): undefined reference to `IID_IDispatch'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0xe51): undefined reference to `IID_IOleInPlaceSite'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0x1129): undefined reference to `GUID_NULL'
../../Lib/Iup/libiupole.a(tOleHandler.o):tOleHandler.cpp:(.text+0x124d): undefined reference to `GUID_NULL'
../../Lib/Iup/libiupole.a(tOleInPlaceSite.o):tOleInPlaceSite.cpp:(.text+0xc8): …Run Code Online (Sandbox Code Playgroud) 我想将我的一个c ++类作为Python模块提供.该类在头文件中声明,Foo.h并以.cpp实现Foo.cpp.(g ++ - 4.5,Ubuntu x86_64).这是一个非常简单的课程:
Foo.cpp:
Foo::Foo() : alfa(1.0), beta(1)
{
}
Foo::~Foo()
{
}
Run Code Online (Sandbox Code Playgroud)
Foo.h:
class Foo
{
public:
Foo()
Foo(const Foo& orig);
~Foo();
double alfa;
int beta;
};
Run Code Online (Sandbox Code Playgroud)
我创建了一个setup.py如Cython教程中所示:
setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'MyDemo',
ext_modules=[
Extension("Foo"
sources=["Foo.pyx"],
include_dirs=[".","../eigen/"],
language="c++"),
],
cmdclass = {'build_ext': build_ext},
)
Run Code Online (Sandbox Code Playgroud)
并按照cython教程的指示编写我的Foo.pyxcython模块:
Foo.pyx
cdef extern from "Foo.h":
ctypedef struct c_Foo "Foo": …Run Code Online (Sandbox Code Playgroud) 我在跑..
gcc -c -I/usr/vt/sample ttssample.c
gcc -L. -lttsapi ttssample.o -o ttsample
Run Code Online (Sandbox Code Playgroud)
我收到以下错误...
ttssample.o: In function `_TTSFile':
ttssample.c:(.text+0x352): undefined reference to `TTSRequestFile'
ttssample.o: In function `_TTSFileEx':
ttssample.c:(.text+0x5e0): undefined reference to `TTSRequestFileEx'
ttssample.o: In function `_TTSBuffer':
ttssample.c:(.text+0x833): undefined reference to `_TTSRequestBuffer'
ttssample.o: In function `_TTSBufferEx':
ttssample.c:(.text+0xabd): undefined reference to `_TTSRequestBufferEx'
ttssample.o: In function `_TTSBuffering_cont':
ttssample.c:(.text+0xcbf): undefined reference to `_TTSRequestBuffer'
ttssample.o: In function `_TTSBuffering_stop':
ttssample.c:(.text+0xf2d): undefined reference to `_TTSRequestBuffer'
ttssample.o: In function `_TTSBuffering_SSML':
ttssample.c:(.text+0x122b): undefined reference to `_TTSRequestBufferSSMLEx'
ttssample.o: In function `_TTSStatus':
ttssample.c:(.text+0x157b): …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试将工厂实施为单身人士.我几乎使用了Singleton模式的教科书示例.这是.h文件:
namespace oxygen{
class ImpFactory{
public:
static boost::shared_ptr<ImpFactory> GetInstance();
private:
static boost::shared_ptr<ImpFactory> mInstance;
};
Run Code Online (Sandbox Code Playgroud)
这是.cpp文件:
#include "impfactory.h"
using namespace oxygen;
using namespace boost;
shared_ptr<ImpFactory> ImpFactory::GetInstance(){
if (mInstance.get() == 0)
mInstance = shared_ptr<ImpFactory>(new ImpFactory());
return mInstance;
}
Run Code Online (Sandbox Code Playgroud)
代码编译,但我收到链接器错误:
../../lib/oxygen/liboxygen.so.3.2.4:未定义引用`oxygen :: ImpFactory :: mInstance'
这目前有三名学生难倒.有任何想法吗?
我在这里,试图找出我的代码有什么问题,但没有成功:(\n我正在编写一个重采样器,但我想这根本没有兴趣,我只是想让你做这个愚蠢的警告消失。无论如何,这是我的代码:
\n\nddc.hpp
\n\n#ifndef __DIGITAL_DOWN_CONVERTER_H__\n#define __DIGITAL_DOWN_CONVERTER_H__\n\n#include <vector>\n#include "interpolator.h"\n\nnamespace ddc {\n void decimate(std::vector<float> &, unsigned int);\n void expand(std::vector<float> &, unsigned int);\n void perform_resampling(std::vector<float>, unsigned int, unsigned int);\n void generate_filter(std::vector<float> &, unsigned int, unsigned int);\n float Sinc(float);\n unsigned int mcd(unsigned int, unsigned int);\n}\n\n#endif\nRun Code Online (Sandbox Code Playgroud)\n\nddc.cpp
\n\n#include "ddc.hpp"\n\nnamespace ddc {\n void perform_resampling(std::vector<float> &data, unsigned int freq_1, unsigned int freq_2) {\n unsigned int i, gcd = mcd(freq_1, freq_2);\n unsigned int downFactor, upFactor;\n std::vector<float> filter;\n\n downFactor = freq_1/gcd;\n upFactor = freq_2/gcd;\n\n generate_filter(filter, 1024 …Run Code Online (Sandbox Code Playgroud) 我正在测试如何在 C 中使用 extern ,因此我为 main.c、test.c、headfile.h 创建三个文件。我想在 headfile.h 中声明变量和函数,在 test.c 中定义,然后在 main.c 中打印出变量并调用函数。它通过使用 Dev c++ 成功运行,但是,当我将完全相同的文件放入VScode 显示错误,指出存在未定义的变量引用
错误消息 在此处输入图像描述
#include <stdio.h>
#include <stdlib.h>
#include"D:\My Documents\Desktop\CODE\c\VScode\externTest\headfile.h"
int gVar = 1;
int main(void)
{
extern float a;
printf("a = %f\n",a);
printf("gVar = %d\n",gVar);
printf("aa = %d\n",aa);
printf("bb = %f\n",bb);
function ();
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
#include <stdio.h>
#include "D:\My Documents\Desktop\CODE\c\VScode\externTest\headfile.h"
float a = 100;
int aa = 200;
float bb = 300;
void function (void){
printf("yeh you got it!!\n");
extern …Run Code Online (Sandbox Code Playgroud)