使用C ++与libpq链接​​错误 [英] Link error with libpq using C++

查看:69
本文介绍了使用C ++与libpq链接​​错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用libpq连接到我的PostgreSQL数据库,并打算在工作后调用预定义的函数.现在,我只输入了conninfo字符串,并测试了连接.最终弄清楚如何在我的项目中包含不同的代码目录和库路径(Windows 7,MinGW编译器上的Netbeans 6.9.1)后,我发现此错误:

I'm trying to use libpq to connect to my PostgreSQL database and intend to call pre-defined functions once I get this working. Right now I just have the conninfo string entered, and test the connection. After finally figuring out how to include different code directories and library paths (Netbeans 6.9.1 on Windows 7, MinGW compiler) in my project, I find this error:

g ++.exe -c -I/C/Program \ Files/PostgreSQL/9.0/include -MMD -MP -MF build/Debug/MinGW-Windows/main.od -o build/Debug/MinGW-Windows/main.o main.cpp

g++.exe -c -I/C/Program\ Files/PostgreSQL/9.0/include -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp

mkdir -p dist/Debug/MinGW-Windows

mkdir -p dist/Debug/MinGW-Windows

g ++.exe -o dist/Debug/MinGW-Windows/toolboxconnect build/Debug/MinGW-Windows/main.o -L/C/Program \ Files/PostgreSQL/9.0/lib -lpq

g++.exe -o dist/Debug/MinGW-Windows/toolboxconnect build/Debug/MinGW-Windows/main.o -L/C/Program\ Files/PostgreSQL/9.0/lib -lpq

c:/Program Files/PostgreSQL/9.0/lib/libpq.dll:无法识别文件:无法识别文件格式
collect2:ld返回1个退出状态

c:/Program Files/PostgreSQL/9.0/lib/libpq.dll: file not recognized: File format not recognized
collect2: ld returned 1 exit status

我搜索了许多主题,原因是为什么它不能被识别,但是人们向其他人建议说这是因为它们运行的​​是64位,并且需要重建dll.我不认为我的PostgreSQL安装附带生成文件来重新编译这些文件,并认为它们可以很好地使用.还有其他原因导致我的链接器不喜欢我的libpq库/其他某种修复程序吗?

I have searched many topics for the reason of why this could not be recognized, but people suggest to others that its because theyre running 64-bit, and would need to rebuild the dlls. I don't think my PostgreSQL install came with makefiles to recompile these, and assumed they would be good to use as they were. Is there any other reason why my linker would not like my libpq library/some other sort of fix?

推荐答案

其他人刚刚在libpq中遇到了类似的问题.

Someone else just had a similar issue with libpq.

在回答之后的讨论中,这是>下载源代码的链接,以便您可以根据需要对其进行重建.有不同的版本,因此请确保下载所需的版本.

From the discussion that followed that answer, here's a link to download the source code so you can rebuild it to suit your needs. There are different versions available, so make sure you download the one you want.

我真的很讨厌只把依赖关系坚持为您的依赖关系不起作用?下载源代码并自己重新编译!"-但可悲的是,这似乎是目前postgres的唯一选择.

I really hate to just stick you with the dependency hell of "Your dependency doesn't work? Download the source and recompile it yourself!" -- but sadly, that seems to be the only option for postgres at the moment.

这篇关于使用C ++与libpq链接​​错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆