是否可以(或根本相关)导出静态库的成员函数?当我“dumpbin /EXPORTS”我的 .lib 文件时,我没有看到任何我定义的类成员。
链接到此 lib 文件成功,但我使用的外部工具无法读取非导出符号。
还尝试添加 .def 文件,但没有结果。
我有两个静态库(a.lib和b.lib)内部,库a有类Foo,但它没有在任何公开可用的包含中公开.库b.lib也有类Foo,它也没有在接口中公开.这些类位于同一名称空间中,并具有相同的构造函数签名.
当我调试或运行可执行文件(使用两个库)时,我发现错误的类lib a而不是lib b创建.试图了解这是如何发生的.这是链接器问题吗?(即类名是相同的,链接器插入它先找到的任何东西)
我想创建自己的静态库。我在 youtube 上观看了 Linux 教程(我找不到任何 mac 教程)。本教程使用命令行工具ar将 .o 文件转换为 .a 文件。我尝试这样做:ar rs library.o在 mac 上但没有成功。我如何在 Mac 上执行此操作?谢谢。
这是输出:
ar: no archive members specified
usage: ar -d [-TLsv] archive file ...
ar -m [-TLsv] archive file ...
ar -m [-abiTLsv] position archive file ...
ar -p [-TLsv] archive [file ...]
ar -q [-cTLsv] archive file ...
ar -r [-cuTLsv] archive file ...
ar -r [-abciuTLsv] position archive file ...
ar -t [-TLsv] archive [file ...]
ar -x …Run Code Online (Sandbox Code Playgroud) 很抱歉,也许我问的问题很愚蠢,但我有一个关于在 android 中链接静态/共享库的问题。
\n我正在创建一个新的C++ Native android studio 项目。构建后,我打开 apk 文件,lib文件夹内放置了libnative-lib.so每个 ABI 的库。APK的大小为3.580\xc2\xa0KB。
但是如果我在内部进行更改CMakeLists.txt以构建像静态库一样的本机库,那么现在我得到了:
add_library(native-lib\n STATIC\n native-lib.cpp)\nRun Code Online (Sandbox Code Playgroud)\n当APK构建时,我找不到静态库(libnative-lib.a)。libapk 中没有文件夹。另外,大小为2.836\xc2\xa0KB。
有人可以解释一下(或给我链接以获取更多信息)该库位于静态构建中的什么位置?
\n在运行时,如果链接静态,则会出现错误:
\nNo implementation found for java.lang.String com.example.myapplication.MainActivity.stringFromJNI() \nRun Code Online (Sandbox Code Playgroud)\n 好吧我在Windows 7上设置Visual Studio C++ 10所以我可以从本书"OpenGL superbible 5th edition"中运行示例程序,但是我有一些主要问题,在获取GLTools和freeglut的时候:
这是我如何设置一切到目前为止.........................
我上网后跟着这些步骤:
首先你要下载过剩或freeglut,然后解压缩它.
- 我从http://www.starstonesoftware.com/OpenGL/上的zip文件中得到了这个
在freeglut文件夹中应该有一个名为VisualStudio2008的文件夹,请进入此目的.
应该有一个名为freeglut的VS项目文件,运行它并在转换窗口出现时单击"完成".然后编译它,如果它完成它说无法启动,这没关系.
现在在同一个文件夹中应该有一个名为Debug的新文件夹,因为你刚刚编译了freeglut :).
在里面你会发现freeglut.dll.这需要分别进入你的system32文件夹或SysWOW64.
除此之外还有一个名为freeglut的文件,其类型将是Object File Library.这需要进入Visual Studio中的lib文件夹.
现在回到主要的freeglut文件夹.应该有一个名为Include的文件夹.在这个名为GL的文件夹和两个文件中.这些需要复制到Visual Studio中的Include文件夹中.
lib和Include文件夹位于VC文件夹中,该文件夹位于Visual Studio文件夹中,对我来说是Microsoft Visual Studio 10.0.
有:) .`
然后我按照以下步骤设置GLTools和freeglut:
这需要计算机上的管理员权限.
一世.将所有freeglut头文件(以.h结尾)复制到该文件夹:C:\ Program Files\Microsoft Visual Studio 10.0\VC\include\GL \
II.将所有GLTools头文件(以.h结尾)复制到C:\ Program Files\Microsoft Visual Studio 10.0\VC\include \
III.将所有freeglut和GLTools库文件(以.lib结尾)文件复制到C:\ Program Files\Microsoft Visual Studio 10.0\VC\lib \
IV.即使您已将GLTools.lib复制到lib文件夹中,您仍可能需要告诉VS2010在编译项目时使用GLTools.lib文件.从菜单选项View→Property Manager打开Property Manager(您需要一个打开的项目来执行此操作).VS IDE的左侧窗格将更改为显示属性管理器.您可以调整此大小以使其更具可读性.如果未显示完整列表,请展开项目,然后双击其中一个Microsoft.Cpp.Win32.user链接以打开用户属性对话框.在Property Manager中,选择Linker→Input,然后单击Additional Dependencies(见下文).在弹出的对话框中添加"GLTools.lib",我还为此添加了feeglut_static.lib!
好吧,所以最后这里是我想要运行的代码:
#include <GLTools.h> // OpenGL toolkit
#include <GLShaderManager.h> // Shader Manager Class
#ifdef __APPLE__
#include <glut/glut.h> // OS …Run Code Online (Sandbox Code Playgroud) 我知道这是一个愚蠢的问题,但仍然存在.
我想在我的项目中使用QJson库.我从官方网站下载了tarball(可能需要提一下我是64位Ubuntu 12.04).该INSTALL文件有以下说明
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=_preferred_path_ ..
make
make install
/sbin/ldconfig, if necessary
Run Code Online (Sandbox Code Playgroud)
正是我遵循的.我已经得到了/include,/lib和shareQJson的文件夹添加到我的/usr/local.
之后,我打开我的IDE(这是QtCreator),并使用以下简单代码创建一个测试项目:
#include <QVariant>
#include <qjson/serializer.h>
int main(int argc, char *argv[])
{
QJson::Serializer s;
QVariantMap map;
map["hello"] = QVariantList() <<"t1"<<"t2";
QByteArray json = s.serialize(map);
}
Run Code Online (Sandbox Code Playgroud)
在#include被处理的很好,所有的类型都认可,自动完成对QJson类工作正常.但是,在尝试编译时,我得到了这个(删除了完整路径以提高可读性):
<...>/QJsonTest/main.cpp:15: undefined reference to `QJson::Serializer::Serializer()'
<...>/QJsonTest/main.cpp:18: undefined reference to `QJson::Serializer::serialize(QVariant const&)'
<...>/QJsonTest/main.cpp:18: undefined reference to `QJson::Serializer::~Serializer()'
<...>/QJsonTest/main.cpp:18: undefined reference to `QJson::Serializer::~Serializer()'
collect2: ld returned …Run Code Online (Sandbox Code Playgroud) 文件ac:
#include<stdio.h>
int main(int argc, const char *argv[])
{
double r = 0;
r = call(10.0,2.0);
printf("r:%lf\n",r);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
函数call()在一个静态库中,如:
文件call.c
#include<stdio.h>
double call(double a,double b){
double c;
c = a + b;
printf("c :%lf\n",c);
return c;
}
Run Code Online (Sandbox Code Playgroud)
我使用的命令是
gcc -c call.c -o call.o
ar rcs libcall.a call.o
gcc -o a a.c -lcall -L.
Run Code Online (Sandbox Code Playgroud)
那么为什么结果不是12?如果我将double类型更改为int类型,则结果为12.
我期待着C++,UDP,跨平台库.
有没有简单的使用和快速(免费为商业purpouse)库?
我想要一个小而独立的图书馆,而不是一个最大或最抽象的解决方案的一部分,提升我不感兴趣(并解释为什么不是一个真正的问题,可能是论坛讨论,但我们现在是偏离主题).如果库是用C++而不是C风格编写的,那也不错.
我有一个mylib.a在Linux下生成的静态库.现在如何将其链接到Windows环境下的项目?在mylib.a给别人打电话提供的功能.我在Linux中构建这个库的原因是因为所有内容都已在Linux中设置.