我在glibc
中构建了一个新的~/glibc/git/glibc/build
。我知道我可以在嵌入到它的路径后使用它来启动程序,并且像这样使用相应的加载器路径:
$ gcc main.c -o main -Wl,--rpath=$HOME/glibc/git/glibc/build -Wl,--dynamic-linker=$HOME/glibc/git/glibc/build/elf/ld-linux-x86-64.so.2
main
将由新的libc启动:
$ objdump -p main
RPATH /home/user/glibc/git/glibc/build
和新的装载机:
$ LD_TRACE_LOADED_OBJECTS=1 ./main
linux-vdso.so.1 (0x00007fff92df2000)
libc.so.6 => /home/user/glibc/git/glibc/build/libc.so.6 (0x00007f1097055000)
/home/user/glibc/git/glibc/build/elf/ld-linux-x86-64.so.2 (0x00007f10973f5000)
我向glibc
安装了新的~/glibc-destdir1
版本2.22。我在/lib64
安装了2.17。我想使用仅在2.22中提供的一些pthread
函数,因此我尝试将gcc
指向使用新的libpthread.so
,但它不起作用。此命令失败:
$ LIBRARY_PATH=$HOME/glibc-destdir1/usr/local/lib gcc -std=c99 -Wl,--rpath=$HOME/glibc/git/glibc/build -Wl,--dynamic-linker=$HOME/glibc/git/glibc/build/elf/ld-linux-x86-64.so.2 thread.c -o thread -pthread
/tmp/ccSxKt9O.o: In function `thr':
thread.c:(.text+0x2f): undefined reference to `pthread_getattr_default_np'
/tmp/ccSxKt9O.o: In function `run_threads':
thread.c:(.text+0x153): undefined reference to `pthread_setattr_default_np'
/tmp/ccSxKt9O.o: In function `verify_affinity_result':
thread.c:(.text+0x4eb): undefined reference to `CPU_ISSET'
/tmp/ccSxKt9O.o: In function `do_affinity_test':
thread.c:(.text+0x571): undefined reference to `CPU_ZERO'
thread.c:(.text+0x58a): undefined reference to `CPU_SET'
/tmp/ccSxKt9O.o: In function `do_guardsize_test':
thread.c:(.text+0xa20): undefined reference to `pthread_getattr_default_np'
collect2: error: ld returned 1 exit status
这甚至可以在这里使用新的pthread
和libc
吗?我知道一个旧的libc
仍然用于构建这个程序,libc
作为一个整体包含很多包,它们都必须匹配,但也许有办法做我想要的或我的不足之处是不正确的?
答案 0 :(得分:0)
我修复了它,结果发现新libc安装中的/usr/local/lib/libpthread.so.0
指向不存在的libpthread.so.0
。我只是将其修改为指向同一目录中的class Program
{
static void Main(string[] args)
{
Console.WriteLine("hello World");
System.Uri url = new System.Uri("http://192.168.1.12:81/WebService/BIITAlumni.svc/UploadImage");
string filePath = @"F:\temp\Desert.jpg";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = "application/octet-stream";
request.Method = "POST";
request.ContentType = "image/jpeg";
using (Stream fileStream = File.OpenRead(filePath))
using (Stream requestStream = request.GetRequestStream())
{
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int byteCount = 0;
while ((byteCount = fileStream.Read(buffer, 0, bufferSize)) > 0)
{
requestStream.Write(buffer, 0, byteCount);
}
}
string result;
using (WebResponse response = request.GetResponse())
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
result = reader.ReadToEnd();
}
Console.WriteLine(result);
}
}
。