繁体   English   中英

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

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

在 Cygwin / Windows 下为 Node.js 构建本机模块:

我有一个monkey.cc文件:

#include <monkey/monkey.h>

跑步

node-waf configure build

我得到以下

'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

然后出现以下错误:

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

monkeyFoomonkey.h中定义,该目录位于名为monkey的目录中。 我正在从包含monkey目录和monkey.cc文件的目录运行上述命令。

编辑:

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'

我错过了什么???

那是 linker 错误,而不是编译器错误。 您对 function 有定义吗? (不仅仅是一个声明。)你确定它被链接了吗?

在 wscript 中添加monkey.lib='crypto'

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM