Plaan c++, postgre, pdf

Vastavalt sellele kuidas mul vaba ajaga on annan tead kuidas projekt areneb.

Eesmärk: Vastavalt sisendandmetele sooritatakse postgreSQL andmebaasis päring ning kasutades programmeerimiskeelt C++ tekitatakse PDF fail mis hiljem prinditakse.

Kasutatavad ressursid:
Programmeerimiskeel – C/C++
PostgreSQL db layer for C++ – libqxx (http://pqxx.org/development/libpqxx/)

Alustan vaikselt C postgreSQL connect testi.
Vajalikud headerid:
libpgeacy.h – port install libpgeacy
libpq-fe.h – see tundub poevat postgre dev paketis – fink install postgresql82-dev

Hetkel on asi sellises seisus ja kell on 00:30 aitab. Magama:
make all
Building target: tousuleht
Invoking: MacOS X C Linker
gcc -o “tousuleht” ./pgconnect.o
Undefined symbols:
“_connectdb”, referenced from:
_main in pgconnect.o
“_fetch”, referenced from:
_main in pgconnect.o
“_doquery”, referenced from:
_main in pgconnect.o
“_disconnectdb”, referenced from:
_main in pgconnect.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [tousuleht] Error 1

Selgus et MAC OS X ei oma sellist tooli nagu ldd aga omab hoopis otool -L

linux.ee pealt aidati ka:

[17:17] <Kang> Margusja_: postgres’i teek tundub puudu olevat.
[17:17] <Kang> -lpsql
[17:19] <kaups_AU> Margusja_: -lpgsql ?
[17:19] <Kang> failinimi on kuju libXYZ.so või libXYZ.a
[17:19] <kaups_AU> või mis iganes selle postgresi libra nimi võiks olla
[17:20] <Kang> sellele vastavalt gcc võti on -lXYZ
[17:21] <jussuf> -lpq peaks postgresi lib olema

Peale väikest otsimist paigaldasin fink abil libpqxx2 ja libpqxx2-shlibs

Jälle üks fakt, et igasugused poolautomaatsed builderid on saatanast.
kasutasin käsureal gcc asemel g++ compilaatorit ja hetkel tundub et mul on vajalikud libraryd olemas
libpqxx on see mida ma siis vajan.

Ja mida me veel õppisime. gcc on c compiler ja g++ on c++ compiler.

Kellelgi on sama probleem: http://archives.postgresql.org/pgsql-interfaces/2003-01/msg00115.php

Uhh nii!
Sain ka Mac OS X 10.5.2 peal postgre connection algfaasi kokku.
kasutasin C library (libpq) (C koodis #include libpq-fe.h)
Kuna gcc ei leidnud kohe libpq libraryt siis tuli minu süsteemis talle see ette anda -L/gw/lib -lpq – Selgitame:
-l lingib mingi library koodi külge. syntax: -lXXXX kus XXXX on mingi library, antud juhul oli tegu libpq kus lib jäetakse siis ära. Süsteemis asus library /sw/lib/libpq.a

Hetkel on kenasti asi seal maal, et postgresi baasiga on korralik ühendus olemas kasutades libpq ja C programmeerimiskeelt. Samuti saan andmebaasis andmeid kenasti lugeda ja kuvada.

Tänase õhtu nokitsemine lõppes sellega, et saan vastava CODE sisestamisega vastu vastava CODE andmed.

Asi on siis niikaugel et postgreSQL-ist saan seda mida tahan ja C array-sse suudan ka kogu selle kola kenasti panna.

Natuke nokitsemist ja Mac OS X 10.5 pdflib pakk peal ja kompilaator ka rahul.

Probleeme oli korra mõningate funktioonide leidmisega:

“_HUnlock”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_CurResFile”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
“_FSpOpenDF”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FMGetFontFormat”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FSpOpenResFile”, referenced from:
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FMGetFontContainer”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfontfile in libpdf.a(ft_hostfont.lo)
“_HLock”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_GetResource”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_CopyCStringToPascal”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfontfile in libpdf.a(ft_hostfont.lo)
“_GetEOF”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FMGetFontFromFontFamilyInstance”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_CloseResFile”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FSpGetFInfo”, referenced from:
_pdc_init_output in libpdf.a(pc_output.lo)
“_FSGetCatalogInfo”, referenced from:
_FSPathMakeFSSpec in libpdf.a(pc_file.lo)
“_FSpSetFInfo”, referenced from:
_pdc_init_output in libpdf.a(pc_output.lo)
“_UseResFile”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FSClose”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FSpMakeFSRef”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FMGetFontFamilyFromName”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_ReleaseResource”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FSRefMakePath”, referenced from:
_FSMakePath in libpdf.a(pc_file.lo)
“_FSPathMakeRef”, referenced from:
_FSPathMakeFSSpec in libpdf.a(pc_file.lo)
“_PBMakeFSRefSync”, referenced from:
_FSMakePath in libpdf.a(pc_file.lo)
“_Get1IndResource”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
“_Get1NamedResource”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FSOpenResourceFile”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_GetHandleSize”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_ResError”, referenced from:
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_Count1Resources”, referenced from:
_pdf_get_metrics_type1 in libpdf.a(p_type1.lo)
_pdf_t1open_fontfile in libpdf.a(p_type1.lo)
“_FSRead”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
ld: symbol(s) not found

Need lahenesid vastavalt siis kompilaatorile -framework võtmetega antavate parameetritega:

gcc -L/sw/lib/ -lpq -I /sw/include/postgresql/ -I/sw/include/ -lpdf -framework CoreServices pgconnect.c -o pgconnect

Peale seda kompilaator kaebas:Undefined symbols:
“_FMGetFontFormat”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FMGetFontContainer”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfontfile in libpdf.a(ft_hostfont.lo)
“_FMGetFontFromFontFamilyInstance”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
“_FMGetFontFamilyFromName”, referenced from:
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
_fnt_get_hostfont in libpdf.a(ft_hostfont.lo)
ld: symbol(s) not found
collect2: ld returned 1 exit status

Puudu oli Fonts.h mis asus Mac OS X ApplicationServises framework kaustas.
Lisasime veel ühe framework-i ja kompilaator rahul
gcc -L/sw/lib/ -lpq -I /sw/include/postgresql/ -I/sw/include/ -lpdf -framework CoreServices -framework ApplicationServices pgconnect.c -o pgconnect

PDF fail luuakse kenasti – hetkel on küll loodava faili taustal PDFLIB reklaamurl.

One thought on “Plaan c++, postgre, pdf

Leave a Reply