Has anyone tried to statically link the Postgres client libs into a project? - linker

I'm using Embarcadero® C++Builder 11 Version 28.0.44940.9541. Windows 11.
I am building a 32 bit client, using FireDac, for a customer that is using Postgres. I've tried dropping the actual PG 32 bit lib's in the project folder and adding them to the project in the IDE as well as using the #pragma statements in code, again with the libs in the project folder. The project folder is included in the Dirs and Conds. in the project options.
I have already converted the libs below to OMF using the coff2omf from Embarcadero, due to the COFF linker complaints.
#pragma link "iconv.lib"
#pragma link "libintl.lib"
#pragma link "libpq.lib"
#pragma link "libcrypto.lib"
#pragma link "libssl.lib"
When I move the executable to client machine, it fails with the can't find vendor client lib.
AS a side note, I need to statically link as the customer would rather not have other files distributed with the software.
Edit:
I need to statically link either 32 or 64 bit postgres libraries into my executable and need help as to how to get this done?

Related

Having Difficulty Integrating JSON Library with My AVR Microcontroller Code

I am a relatively inexperienced C developer with no previous experience in integrating libraries made by other developers into existing projects.
Basically, I need a means of parsing JSON data in an AVR microcontroller for a university project. To this end I attempted to download and integrate jansson (https://github.com/akheron/jansson) into my existing build of the microcontroller code. I am working with Atmel Studio in Windows 10, but I have also installed Code::Blocks with MinGW GCC (on the same Windows 10 installation) for the purpose of building the library, and to attempt to integrate the library into a native Windows application. So far, neither has been successful, and I get the same errors. All of the online resources I've found so far have been to basic to be useful, or well beyond my comprehension.
This is what I have done thus far:
I began by attempting to build the software and then integrate it into an existing project per the instructions in https://jansson.readthedocs.io/en/2.11/gettingstarted.html. I installed CMake, built the project files for Code::Blocks with cmake.exe -G “CodeBlocks - MinGW Makefiles”, then opened the project and built everything. A few of the targets (I believe related to testing) failed to build, but jansson itself built and output libjansson.a to the \lib\ directory, so I didn’t think too much of it.
That is as far as I’ve been able to get. In both Atmel Studio and Code::Blocks, I do the same thing: add jansson.h to the relevant include paths, add #include “jansson.h” to all of the relevant files, and add libjansson.a as a library in each IDE’s respective linker options. I’ve tried various things like adding and removing flags to the linker, but the output is always “cannot find -ljansson”, “undefined reference to ‘json_object_seed’” (which is a function in the API I’m calling for no reason other than to see if the project has built properly) and/or “ld returned 1 exit status”.
I cannot help but feel as if the issue is with the line “cc -o prog prog.c -ljansson” in the documentation linked above. I really just don’t understand how to set up the linker properly to get the project to build.
If anyone could give some insight into what I’m doing wrong/the correct way to link this library I would appreciate it a lot.
The library itself should be built with appropriate toolchain. I assume that you built your library twice, one version using MinGW toolchain and other with avr-gcc toolchain.
If you compile target application and linker cannot find library, then try to add path of directory that contains *.a file of library to linker settings (linker search path). Let's say you have: /path/to/lib/libjansson.a
In Code::Blocks: Project → Build options → Search directories → Linker add /path/to/lib/. Then it should link with include path set, for example: cc -o prog prog.c -ljansson -L/path/to/lib/
In Atmel Studio when you add a library in Solution Explorer → Libraries → Add Library it should automatically add library search path to linker options. If you check Project → Properties → AVR/GNU Linker there should be (between other options): -Wl,-ljansson -Wl,-L"/path/to/lib/"
If you copied library files (libjansson.a and jansson.h) to your application's project directory, it will be convenient to use relative paths to library files.

What files can be safely deleted from the MinGW-w64 binaries?

I am using the MinGW-w64 installer found here:
https://mingw-w64.org/doku.php/download/mingw-builds
Installing to a directory creates a folder called mingw32 or mingw64 that contains the compiler. I already know that the additional batch script, HTML link, and uninstall executable in the same directory can be deleted.
The mingw32/64 folder contains these folders:
bin
etc
include
lib
libexec
licenses
opt
share
i686-w64-mingw32 (mingw32) or x86_64-w64-mingw32 (mingw64)
I only wish to compile with C and nothing else. So what files can I delete in order to reduce the file count because the compiler contains files for Ruby, Fortran and other languages which as I stated, I don't need it.
Why are people still using Mingw or Mingw64 instead of TDM-GCC ? You have to rely on the default builds or build it yourself from source. Trying to install it on your own terms sucks.
TDM-GCC on the other hand, you can specify where and which components to install as you wish. You can upgrade or remove it without any worries. It's more fast, easy,modern and equivelant these days.
Now for your question, you can download and install TDM-GCC by it's installer. I don't really think you need any further instructions as a 5 year old would understand how to use it. Just select only the components required for c.
If you don't understand,I would gladly help you more if needed. ^_^
If you want a smaller GCC toolset, try MinGW Distro.
Scroll down to "How To Build Your Own Distro", download components-14.1.7z, extract it, extract binutils 2.27 and GCC 6.3.0 inside the same folder. The total size is about 270MB.
as far as i know the minimum are yours
1, bin
5. libexec
not all tools in bin you may need but generally i would hold both of those dirs
you also ned libraries and headers if you want to build abainst standard c library and windows.h, so
include
lib
is also needed (hovever part of it may contain also headers and libraries for c++ standard library) all those main 3 libs are kinda mixed there afaik so it might be a bit hard to find what comes for what

Not able to upload code on CC2538dk board from Ubuntu 12.04 command line

I have a CC2538dk board. I am using Ubuntu 12.04 and cloned Contiki repository from github. I was able to compile all the code in Contiki using make TARGET=cc2538dk hello-world, but I'm not able to upload the code to the CC2538dk board from command line.
The error I'm getting when I ran make TARGET=cc2538dk hello-world.upload is as below.
make: No rule to make target `hello-world.upload'. Stop.
I used to use TI's Uniflash tool (CCS_Uniflash v2.2) to upload the the .elf binary, but it is not available in Contiki.
There is no make target for uploading to CC2538dk boards. According to the documentation one should use TI's UniFlash.
I had success compiling the contiki examples on a separate computer, then using Code Compose Studio v 5.4 to import my binaries (ELF files) to an empty CC2538 project, then debug it from there in order to get it loaded onto the board. Definitely not ideal, but it works.
Setup:
Compile contiki source and examples from instantContiki
move the example directory, included blink.elf to windows machine with CCS 5.4 installed
make a new project in CCS, select Other Examples->Empty CC2538 Project
Import a C/C++ executable, then using the GNU Elf reader, select the blink.elf file you moved over
copy+paste the CC2538SF53.ccxml and the cx2538xf53_ccs.cmd to the new project, and try to debug using those configurations.
The reason this seems to work is that the xds100v3 drivers that come with the board's install disc and the uniflash tool don't seem to work right and just give me any number of errors. There's a black-magic-configuration-combination of the CCS 5.4 for Window's drivers/Other Example's CC2538SF53.ccxml that was the only way I was able to connect to the target.

Gwan include scripts

I am currently trying to import some libraries into my Gwan C script. I have read through the manual and am using #pragma include to include the folder that my libraries are in, and then use #pragma link to actually include the libraries, but when I run the script it error and says /usr/bin/ld: cannot find -lxxxx.a
Heres current code
#pragma include "/opt/Gwan/libraries/xxx"
#pragma link "xxxx.a"
current Gwan version 4.3.11. Thanks, any help will be appreciated
[EDIT]
All is working fine now, changed all my libraries to shared and placed them in /usr/lib
While you can link object code and static libraries with G-WAN scripts, you should rather use a dynamic library because it will only be loaded once in memory.
Do you succeed in running the (many) G-WAN examples that use third-party libraries?
(libsqlite, libcairo, libmySQL, libcURL, liboauth, libmemchached, ImageMagick, etc.)
Don't forget that you must indicate the library file name without the starting "lib" prefix (ie: sqlite3 for libsqlite3.so).
Also, libraries compiled for 64-bit won't work with G-WAN 32-bit (and vice-versa).
If this can help, there's a G-WAN FAQ dedicated on libraries which gives tips and tools to check for possible problems.
Maybe you should give the whole library names instead of the xxx in your example.

How can I link the source path of a compiled library to a different location in Eclipse?

I've installed the msp430-gcc compiler and associated tools to do some open-source msp430 development at home using Eclipse. I'm developing on a slightly older Macbook Pro running OS X Lion and installed the tools using MacPorts. I'm running Eclipse 3.7.2 with the CDT and GCC Cross Compiler Support plug-ins. I have a simple empty main() written that compiles and links just fine.
The ELF parser lets me view the contents of the ELF binary just fine with the exception of one component; when I try to view the contents of the startup code in crt0.S, it gives me a blank file. When I click on the crt0.S component of the ELF, the filename bar at the bottom of the Eclipse window shows "/opt/local/var/macports/build/_Volumes_work_mports_dports_cross_msp430-gcc/msp430-gcc/work/gcc-4.6.3/gcc/config/msp430/crt0.S". This makes sense because of my MacPorts install of msp430-gcc. crt0.S is archived into /opt/local/lib/gcc/msp430/4.6.3/libcrt0.a on my machine.
What I want to be able to do is tell Eclipse to look elsewhere for the source files for the libraries that are automatically linked when I build with the msp430-gcc toolchain. This would presumably include everything in /opt/local/lib/gcc/msp430/4.6.3/. I started by downloading the source for mspgcc-20120406 (the version in my MacPorts install) and applying the gcc patchfile to an empty directory tree. This created the gcc/config/msp430 directory, including the crt0.S and crt0ivtbl.S files.
What I have had no luck accomplishing is telling Eclipse to look in ~/Developer/mspgcc-20120406/gcc-4.6.3/config/msp430/ instead of the path that's in the already-built libcrt0.a. I tried playing around with the Project Preferences->Paths and Symbols->Source Location window, but didn't have much luck. I searched through this website and on Google and the closest thing I came up with was this question but it doesn't "smell" like the right answer.
I would like to avoid solutions that involve moving the library source into my project. I'd rather have a solution that will work for multiple projects.
All help is greatly appreciated! Thanks in advance.
Try and check if the Eclipse linked resource could help you declare that external directory from within your Eclipse project here.
Linked resources are files and folders that are stored in locations in the file system outside of the project's location. These special resources can be used to add files and folders to your project that for some reason must be stored in a certain place outside of your project. For example, a linked folder can be used to store build output separately from your source files.
I find interesting how you can define that linked resource:
Linked resource target paths can be either defined as absolute paths, or relative to a path variable.
Since you can define it relative to (for instance) your Eclipse project location PROJECT_LOC, you can then setup your resource in a way which won't change between two environments.

Resources