我试图编译一个开源项目的二进制文件,以便我们的用户不必自己编译它.
我注意到在一台32位ubuntu机器"A"上创建的一些二进制文件在32位机器"B"上不起作用,并且报告了丢失.so文件的错误.
但是,如果我在机器"B"上从头开始编译,那么所有错误都消失了.
是否有任何理由为什么编译目标机器上的代码会使这些错误消失?我只运行"./configure"和"make" - 而不是"make-install",所以它不像我在全球范围内制作这些.so文件.
可能是编译器检测到系统库中缺少.so文件,在这种情况下将静态库链接到可执行文件中?
Ubuntu如何编译其软件包以便在所有x86机器上运行i386软件包?
我偶然发现了一些奇怪的行为:在我启动应用程序之前,我已将LD_LIBRARY_PATH设置为包含所有所需库的本地lib目录.启动后,我有部分(大部分)libs从LD_LIBRARY_PATH加载,但有一些是从标准/ usr/lib加载的(例如/usr/lib/libQtNetwork.so.4,/usr/lib/libSM.so. 6).所有这些库都包含在LD_LIBRARY_PATH中列出的目录中.任何人都可以解释为什么我有这样的行为?我对Linux世界不是很熟悉,但是本文说我的方法应该有效
PS如果我将/ usr/libs重命名为其他东西,我将使用从我的libs位置使用的所有lib运行我的应用程序
预先感谢!
为什么我有这个简单的代码
void voidFunct() {
printf("voidFunct called!!!\n");
}
Run Code Online (Sandbox Code Playgroud)
我将其编译为动态库
gcc -c LSB.c -o LSB.o
gcc -shared -Wl -o libLSB.so.1 LSB.o
Run Code Online (Sandbox Code Playgroud)
我使用ctypes从python解释器调用函数
>>> from ctypes import *
>>> dll = CDLL("./libLSB.so.1")
>>> return = dll.voidFunct()
voidFunct called!!!
>>> print return
17
Run Code Online (Sandbox Code Playgroud)
为什么从void方法返回的值是17和不None相似?谢谢.
当我将null指针传递给我时遇到崩溃dlclose.
我应该在打电话前检查空dlclose吗?
POSIX对此没有任何说明:http: //pubs.opengroup.org/onlinepubs/7908799/xsh/dlclose.html
它是未定义的行为还是dlclose实现中的错误?
linux posix shared-libraries dynamic-loading dynamic-library
WinMain是一个"替换"默认主入口点'main'的函数.
然后,用户可以定义其主要入口点
int WINAPI WinMain(...) { }
Run Code Online (Sandbox Code Playgroud)
这种封装是如何完成的?
嗯,最有可能的是,在某些时候它看起来像这样:
int main() // This must be defined somewhere in windows.h
{
return WinMain(...);
}
Run Code Online (Sandbox Code Playgroud)
问题:如何完成我自己的封装,然后调用WinMain?注意:我创建的库是一个DLL,所以它看起来像这样:
// This is the minimal code for the application which uses 'MyLibrary'
#pragma comment(lib, "MyLibrary.lib")
include "MyLibrary.h"
void Main(MyCustomParameter *params)
{
// Write user code here
}
Run Code Online (Sandbox Code Playgroud)
但问题是,DLL不"知道"该Main()函数,因此会抛出"未解析的外部符号"编译错误.那么如何将其封装起来呢?
我需要检查是否存在动态库,以便以后可以安全地调用使用该库的函数。
有没有多平台的方式来检查这一点?我的目标是MS Windows 7(VC ++ 11)和Linux(g ++)。
我在Windows 8上运行带有PHP 5.5.9的Apache 2.4.7,安装了PHPUnit,此警告图像“警告”开始弹出。

是的,我启用了php.ini中的扩展加载以及“ extension_dir”来更正文件夹,并且该文件夹中有一个名为“ php_pdo_oci.dll”的文件。我尝试使用不同的apache和php版本,但没有帮助。任何建议如何解决此问题?
我正在Rust中编写一个简单的基于插件的系统,以获得使用该语言的一些技能和经验.我的系统动态加载库并在运行时执行它们以初始化每个插件.我在从动态加载的库中执行代码时遇到了一个有趣的段错误问题.
这是加载和运行插件初始化函数的代码:(这个位工作正常)
pub fn register_plugins<'rp>(&'rp mut self)
{
let p1 = match DynamicLibrary::open(Some("librust_plugin_1.so")) {
Ok(lib) => lib,
Err(error) => fail!("Could not load the library: {}", error)
};
let s1: extern "Rust" fn(&PluginSystem) = unsafe {
match p1.symbol("init") {
Err(error) => fail!("Could not load function init: {}", error),
Ok(init) => mem::transmute::<*mut u8, _>(init)
}
};
s1(&self.ps);
}
Run Code Online (Sandbox Code Playgroud)
这是插件库中的init函数:
#[no_mangle]
pub fn init(ps:&mut PluginSystem)
{
ps.register_plugin("ps1"); //<-- Segfault is in this method
ps.add_new_hook_with_closure("onLoad", "ps1", "display greeting.", 10, test1);
println!("Initialized plugin.");
}
Run Code Online (Sandbox Code Playgroud)
如评论所述,segfault发生在名为ps的PluginSystem结构的register_plugin函数中.这个结构是从调用方法借来的(在第一个代码块中). …
我正在开发Android Library项目,并希望将Picasso添加到我的库中.我注意到不同的库使用不同的方法来做到这一点:
所以问题是:将第三方库添加到Android库项目的最佳方法是什么?我的意思是有助于简化最终用户的库集成过程并避免版本冲突和其他潜在问题的方式.特定方法的优点和缺点是什么?
我正在开发一个跨平台项目,我必须加载动态库。因此,我围绕 dlopen/loadLibrary 创建了一个非常基本的独立于平台的模板化包装类,它的作用类似于工厂类并返回unique_ptr<T>lib 对象。
但这在大多数情况下是非常不切实际的,因此我想知道如何设计一个简单的包装器来执行以下操作:
这存在吗?如果没有,最好的方法是什么?
到目前为止我的实现:
#pragma once
#include <memory>
#include <iostream>
#if _WIN32
#include <Windows.h>
#else
#include <dlfcn.h> //dlopen
#endif
namespace utils
{
template <class T>
class DynLib
{
public:
DynLib() = default;
~DynLib()
{
if (handle_)
closeLib(handle_);
};
private:
bool printLibError()
{
#if _WIN32
std::cerr << GetLastError() << std::endl;
#else
std::cerr << dlerror() << std::endl;
#endif
return false;
}
void …Run Code Online (Sandbox Code Playgroud) dynamic-library ×10
c++ ×3
linux ×3
android ×1
ctypes ×1
dll ×1
dlopen ×1
g++ ×1
maven ×1
php ×1
posix ×1
python ×1
return-value ×1
rust ×1
visual-c++ ×1