
Hi. I'm very new to Haskell, but I'm trying to compile a simple program that uses HDBC with ODBC. I am working on an amd64 Gentoo Linux system. I've installed hdbc and hdbc-odbc with the unixOBDC bindings. So far, I created a small hello world type program. It doesn't use any HDBC functionality yet, but I inserted the following two lines at the top to see if I could compile correctly: import Database.HDBC import Database.HDBC.ODBC However, when I try to compile I get this: $ ghc Main.hs Main.o: In function `s1cY_info': (.text+0x1ef): undefined reference to `__stginit_HDBCzmodbczm1zi1zi3zi0_DatabaseziHDBCziODBC_' Main.o: In function `s1cY_info': (.text+0x1fb): undefined reference to `__stginit_HDBCzm2zi2zi6zi1_DatabaseziHDBC_' collect2: ld returned 1 exit status Though, these errors do not show up when I run the .hs file with runhaskell. I'm guessing I just don't know how to link to the correct library or libraries. I tried adding -lodbc to the ghc line but that did not help. In /usr/lib I see libodbc.so, as well as the directories hdbc-1.1.3 and hdbc-odbc-1.1.3.0. I would appreciate any guidance. -- frigidcode.com theologia.indicium.us

Use ghc --make.
I heard that the newest version of ghc uses --make implicitely so you
don't have to specify it, but I haven't actually experienced it myself
yet.
On Fri, May 13, 2011 at 1:35 AM, Christopher Howard
Hi. I'm very new to Haskell, but I'm trying to compile a simple program that uses HDBC with ODBC. I am working on an amd64 Gentoo Linux system. I've installed hdbc and hdbc-odbc with the unixOBDC bindings. So far, I created a small hello world type program. It doesn't use any HDBC functionality yet, but I inserted the following two lines at the top to see if I could compile correctly:
import Database.HDBC import Database.HDBC.ODBC
However, when I try to compile I get this:
$ ghc Main.hs Main.o: In function `s1cY_info': (.text+0x1ef): undefined reference to `__stginit_HDBCzmodbczm1zi1zi3zi0_DatabaseziHDBCziODBC_' Main.o: In function `s1cY_info': (.text+0x1fb): undefined reference to `__stginit_HDBCzm2zi2zi6zi1_DatabaseziHDBC_' collect2: ld returned 1 exit status
Though, these errors do not show up when I run the .hs file with runhaskell.
I'm guessing I just don't know how to link to the correct library or libraries. I tried adding -lodbc to the ghc line but that did not help. In /usr/lib I see libodbc.so, as well as the directories hdbc-1.1.3 and hdbc-odbc-1.1.3.0. I would appreciate any guidance.
-- frigidcode.com theologia.indicium.us
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Friday 13 May 2011 07:44:18, David McBride wrote:
Use ghc --make.
This. You rarely need to specify libraries and packages with make. For nontrivial projects, use Cabal.
I heard that the newest version of ghc uses --make implicitely so you don't have to specify it, but I haven't actually experienced it myself yet.
Yup, as of ghc-7, --make is the default (I still type it more often than not, muscle memory).

On 13 May 2011 07:50, Daniel Fischer
On Friday 13 May 2011 07:44:18, David McBride wrote:
Use ghc --make.
This. You rarely need to specify libraries and packages with make. For nontrivial projects, use Cabal.
Personally I'd recommend even trivial projects to use Cabal. If it's a "project" and not just a 15 minute job, cabal init. It takes 2~ minutes to edit the resulting Cabal file with the libs you need. cabal-dev would also be very helpful to newbies. The amount of time I wasted as a newbie reinstalling packages because I had conflicts with existing installed packages... cabal-dev solves this and lets you get back to hacking.

On Friday 13 May 2011 08:17:47, Christopher Done wrote:
On 13 May 2011 07:50, Daniel Fischer
wrote: On Friday 13 May 2011 07:44:18, David McBride wrote:
Use ghc --make.
This. You rarely need to specify libraries and packages with make. For nontrivial projects, use Cabal.
Personally I'd recommend even trivial projects to use Cabal. If it's a
I certainly wouldn't want to discourage using Cabal for even the smallest things. I thought of a one-off programme, built from two or three files, using only boot packages (say base, containers, arrays, for example) as dependencies as 'trivial'; if all it needs is "ghc --make" with a vanilla ghc from 6.2 to HEAD, you can get away without Cabal. Anything more, definitely cabalise it.
"project" and not just a 15 minute job, cabal init.
I'm a slow typist, I'll grant an hour ;)
participants (4)
-
Christopher Done
-
Christopher Howard
-
Daniel Fischer
-
David McBride