我是C++的新手,调试链接器错误时遇到问题。我在g++编译器中使用wxDev-c++。我创建了一个静态库,该库链接到一个基本项目。该库最初不包含对外部头文件或库的引用,它只是几个简单的测试函数,将两个double值加在一起并返回值。链接到测试项目时,此方法工作正常。但是,我现在正在尝试将FTP合并到该库中,并且出现链接器错误。
目前,测试功能只是试图访问相同的简单加法功能以进行测试,我什至没有调用FTP功能,因为我只是想使测试项目正确编译。
库代码:
DaFTPLib.h:
#ifndef WAVE_H
#define WAVE_H
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/protocol/ftp.h>
namespace Wave
{
class DaFTP
{
public:
DaFTP(char *url, char *login, char *password);
~DaFTP();
const int Download(char* fileName);
static const void DownloadNCWD(char *url, char *fileName, char *login, char *password);
static const void DownloadLAMP();
static double FuncA(double a, double b);
static double FuncB(double a, double b);
private:
char* url, login, password;
wxFTP ftp;
};
}
#endif
#include "DaFTPLib.h"
using namespace std;
char* _url;
char* _login;
char* _password;
wxFTP ftp;
namespace Wave
{
DaFTP::DaFTP(char *url, char *login, char *password)
{
_url = url;
_login = login;
_password = password;
}
DaFTP::~DaFTP(){}
const int DaFTP::Download(char *fileName)
{
int fileSize;
ftp.SetPassive(true);
ftp.SetUser(_login);
ftp.SetPassword(_password);
ftp.Connect(_url);
fileSize = ftp.GetFileSize(fileName);
return fileSize;
}
const void DaFTP::DownloadNCWD(char *url, char *fileName, char *login, char *password)
{
DaFTP daftp(url, login, password);
daftp.Download(fileName);
}
const void DaFTP::DownloadLAMP() {}
double DaFTP::FuncA(double a, double b)
{
return a + b;
}
double DaFTP::FuncB(double a, double b)
{
return a - b;
}
}
#include <cstdlib>
#include <iostream>
#include "../libDaFTP/DaFTPLib.h"
using namespace std;
int main(int argc, char *argv[])
{
double a, b, c;
a = 23.32;
b = 26.68;
c = Wave::DaFTP::FuncA(a, b);
cout << "FuncA val: " << c << endl;
c = Wave::DaFTP::FuncB(a, b);
cout << "FuncB val: " << c << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
wxThread::TestDestroy()'
Objects/MingW/main.o:main.cpp:(.text$_ZN20wxThreadHelperThreadD1Ev[wxThreadHelperThread::~wxThreadHelperThread()]+0x16): undefined reference to的 undefined reference wxThread::〜wxThread()'wxThread::~wxThread()'
../libDaFTP/Output/MingW/libDaFTP.a(DaFTPLib.o):DaFTPLib.cpp:(.text+0x10): undefined reference to的 undefined reference wxFTP::wxFTP()'wxFTP::wxFTP()'
../libDaFTP/Output/MingW/libDaFTP.a(DaFTPLib.o):DaFTPLib.cpp:(.text+0x6c): undefined reference to wxFTP::〜wxFTP()的 undefined reference wxFTP::~wxFTP()'
../libDaFTP/Output/MingW/libDaFTP.a(DaFTPLib.o):DaFTPLib.cpp:(.text+0x1e3): undefined reference to的引用wxFTP::Connect(wxString const&)'wxFTP::GetFileSize(wxString const&)'
../libDaFTP/Output/MingW/libDaFTP.a(DaFTPLib.o):DaFTPLib.cpp:(.text+0x43f): undefined reference to wxFTP::wxFTP()的 undefined reference wxFTP::~wxFTP()'
../libDaFTP/Output/MingW/libDaFTP.a(DaFTPLib.o):DaFTPLib.cpp:(.text$_ZN8wxStringaSERKS_[wxString::operator=(wxString const&)]+0x14): undefined reference to的引用wxStringBase::operator =(wxStringBase const&)'wxStringBase::npos'
../libDaFTP/Output/MingW/libDaFTP.a(DaFTPLib.o):DaFTPLib.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to wxStringBase::InitWith的 undefined reference (字符const *,unsigned int,unsigned int)'最佳答案
but I was under the assumption that when compiling my library any supporting libraries such as the ftp stuff would be compiled in with it.
关于c++ - 引用另一个库的c++静态库的链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8273460/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何
我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion为什么SecureRandom.uuid创建一个唯一的字符串?SecureRandom.uuid#=>"35cb4e30-54e1-49f9-b5ce-4134799eb2c0"SecureRandom.uuid方法创建的字符串从不重复?
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file