简体   繁体   English

C++ 为什么 linker 看不到我的文件?

[英]C++ Why can't the linker see my files?

Building a native module for Node.js under Cygwin / Windows:在 Cygwin / Windows 下为 Node.js 构建本机模块:

I have a monkey.cc file with this:我有一个monkey.cc文件:

#include <monkey/monkey.h>

running跑步

node-waf configure build

I get the following我得到以下

'configure' finished successfully (0.351s)
Waf: Entering directory `/usr/src/build'
[2/2] cxx_link: build/default/monkey_1.o -> build/default/monkey.node build/default/libmonkey.dll.a
Creating library file: default/libmonkey.dll.a

then the following error:然后出现以下错误:

default/monkey_1.o:/usr/src/build/../monkey.cc:144: undefined reference to `_monkeyFoo'

monkeyFoo is defined in monkey.h which is in a directory named monkey . monkeyFoomonkey.h中定义,该目录位于名为monkey的目录中。 I am running the above command from the directory containing monkey directory and monkey.cc file.我正在从包含monkey目录和monkey.cc文件的目录运行上述命令。

EDIT:编辑:

wscript, which is the python script that node-waf runs looks like this: wscript,即 node-waf 运行的 python 脚本,如下所示:

import os

srcdir = '.'
blddir = './build'
VERSION = '0.0.2'

def set_options(opt):
  opt.tool_options('compiler_cxx')

def configure(conf):
  conf.check_tool('compiler_cxx')
  conf.check_tool('node_addon')

def build(bld):
  monkey = bld.new_task_gen('cxx', 'shlib', 'node_addon')
  monkey.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall", "-L/usr/lib", "-lssl"]
  monkey.chmod = 0755
  monkey.target = 'monkey'
  monkey.source = 'monkey.cc'

What am I missing???我错过了什么???

That's a linker error, not a compiler error.那是 linker 错误,而不是编译器错误。 Do you have a definition for the function?您对 function 有定义吗? (Not just a declaration.) And are you sure it's being linked in? (不仅仅是一个声明。)你确定它被链接了吗?

Add monkey.lib='crypto' in the wscript.在 wscript 中添加monkey.lib='crypto'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么C ++看不到我的lua脚本文件? - Why C++ can't see my lua script file? 链接器为什么看不到我的(定义明确的)外部对象? - Why can't linker see my (definitely defined) externals? 为什么我的C ++代码看不到这个C#类成员? - Why can't my C++ code see this C# class member? 为什么我的C ++链接器仅在删除boost共享对象文件后才能工作? - Why does my C++ linker only work after I delete boost shared object files? 看不到我的C ++程序(debian)的输出 - Can t see the output of my c++ program (debian) 为什么链接器不能阻止C ++静态初始化命令惨败? - Why can't the linker prevent the C++ static initialization order fiasco? 为什么gcc链接器看不到我的析构函数? - Why gcc linker does not see my destructor? 为什么我的简单C ++控制台应用程序在Visual Studio 2015中看不到我的简单C ++静态库标头? - Why won't my simple C++ console app see my simple C++ static library headers in Visual Studio 2015? 编译我的 C++ 程序:clang: error: linker command failed with exit code 1(使用 -v 查看调用) - Compiling my c++ program: clang: error: linker command failed with exit code 1 (use -v to see invocation) C#代码无法“查看”我的C ++ dll中的方法 - C# code can't “see” the methods in my C++ dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM