{"action":"created","issue":{"url":"https://api.github.com/repos/mbalmer/luapgsql/issues/7","labels_url":"https://api.github.com/repos/mbalmer/luapgsql/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/mbalmer/luapgsql/issues/7/comments","events_url":"https://api.github.com/repos/mbalmer/luapgsql/issues/7/events","html_url":"https://github.com/mbalmer/luapgsql/issues/7","id":53276962,"number":7,"title":"Fine tuning rockspec","user":{"login":"daurnimator","id":127971,"avatar_url":"https://avatars.githubusercontent.com/u/127971?v=3","gravatar_id":"","url":"https://api.github.com/users/daurnimator","html_url":"https://github.com/daurnimator","followers_url":"https://api.github.com/users/daurnimator/followers","following_url":"https://api.github.com/users/daurnimator/following{/other_user}","gists_url":"https://api.github.com/users/daurnimator/gists{/gist_id}","starred_url":"https://api.github.com/users/daurnimator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daurnimator/subscriptions","organizations_url":"https://api.github.com/users/daurnimator/orgs","repos_url":"https://api.github.com/users/daurnimator/repos","events_url":"https://api.github.com/users/daurnimator/events{/privacy}","received_events_url":"https://api.github.com/users/daurnimator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-01-02T20:48:33Z","updated_at":"2015-07-31T20:09:44Z","closed_at":null,"body":"Hi Marc,\r\n\r\nThe current [rockspec available up on luarocks](https://rocks.moonscript.org/manifests/luarocks/luapgsql-scm-2.rockspec) doesn't work for me.\r\nI spent some time trying to get it down to the minimum required:\r\n\r\n```lua\r\npackage = \"luapgsql\"\r\nversion = \"scm-3\"\r\nsource = {\r\n   url = \"git://github.com/mbalmer/luapgsql\";\r\n}\r\ndescription = {\r\n   summary = \"A Lua Binding for PostgreSQL\";\r\n   homepage = \"http://github.com/mbalmer/luapgsql\";\r\n   license = \"3-clause BSD\";\r\n}\r\ndependencies = {\r\n   \"lua >= 5.1, < 5.3\";\r\n}\r\nexternal_dependencies = {\r\n   POSTGRESQL = {\r\n      header = \"postgres_fe.h\";\r\n   };\r\n   PQ = {\r\n      header = \"libpq-fe.h\";\r\n      library = \"pq\";\r\n   };\r\n   platforms = {\r\n      linux = {\r\n         -- for strlcpy\r\n         LIBBSD = {\r\n            header = \"bsd/bsd.h\";\r\n            library = \"bsd\";\r\n         };\r\n      };\r\n   };\r\n}\r\nbuild = {\r\n   type = \"builtin\";\r\n   modules = {\r\n      pgsql = {\r\n         sources = \"luapgsql.c\";\r\n         incdirs = { \"$(POSTGRESQL_INCDIR)\" };\r\n         libdirs = { \"$(POSTGRESQL_LIBDIR)\" };\r\n         libraries = { \"pq\" };\r\n      };\r\n   };\r\n   platforms = {\r\n      linux = {\r\n         modules = {\r\n            pgsql = {\r\n               incdirs = { [2] = \"$(LIBBSD_INCDIR)\"; };\r\n               libdirs = { [2] = \"$(LIBBSD_LIBDIR)\"; };\r\n               libraries = { [2] = \"bsd\"; };\r\n               defines = { \"_GNU_SOURCE\" }; -- for asprintf\r\n            };\r\n         };\r\n      };\r\n   };\r\n}\r\n```\r\n\r\nThe `header = \"postgres_fe.h\";` should be correct, as that is the actual `#include` in the code: https://github.com/mbalmer/luapgsql/blob/master/luapgsql.c#L36\r\n\r\nThis works on my arch linux system, with the postgres server installed. You can see an example invocation here:\r\n```\r\n$ sudo luarocks install luapgsql-scm-3.rockspec POSTGRESQL_INCDIR=/usr/include/postgresql/server\r\nUsing luapgsql-scm-3.rockspec... switching to 'build' mode\r\nCloning into 'luapgsql'...\r\nremote: Counting objects: 13, done.\r\nremote: Compressing objects: 100% (11/11), done.\r\nremote: Total 13 (delta 0), reused 7 (delta 0)\r\nReceiving objects: 100% (13/13), 99.58 KiB | 0 bytes/s, done.\r\nChecking connectivity... done.\r\ngcc -O2 -fPIC -I/usr/include -c luapgsql.c -o luapgsql.o -D_GNU_SOURCE -I/usr/include/postgresql/server -I/usr/include\r\ngcc -shared -o pgsql.so -L/usr/lib luapgsql.o -L/usr/local/lib -L/usr/lib -Wl,-rpath,/usr/local/lib: -Wl,-rpath,/usr/lib: -lpq -lbsd\r\nUpdating manifest for /usr/lib/luarocks/rocks-5.2\r\nluapgsql scm-3 is now built and installed in /usr (license: 3-clause BSD)\r\n```\r\n\r\nI was wondering which of the bsd bits need to remain:\r\n  - does libpq need to be linked as `-lpostgres`?\r\n  - why was `postgres.h` required?\r\n\r\nlibbsd still needs to be included because of `strlcpy`."},"comment":{"url":"https://api.github.com/repos/mbalmer/luapgsql/issues/comments/126801951","html_url":"https://github.com/mbalmer/luapgsql/issues/7#issuecomment-126801951","issue_url":"https://api.github.com/repos/mbalmer/luapgsql/issues/7","id":126801951,"user":{"login":"markuman","id":3920157,"avatar_url":"https://avatars.githubusercontent.com/u/3920157?v=3","gravatar_id":"","url":"https://api.github.com/users/markuman","html_url":"https://github.com/markuman","followers_url":"https://api.github.com/users/markuman/followers","following_url":"https://api.github.com/users/markuman/following{/other_user}","gists_url":"https://api.github.com/users/markuman/gists{/gist_id}","starred_url":"https://api.github.com/users/markuman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markuman/subscriptions","organizations_url":"https://api.github.com/users/markuman/orgs","repos_url":"https://api.github.com/users/markuman/repos","events_url":"https://api.github.com/users/markuman/events{/privacy}","received_events_url":"https://api.github.com/users/markuman/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T20:09:44Z","updated_at":"2015-07-31T20:09:44Z","body":"why `< 5.3` ? It seems to work without any problems with lua 5.3 and postgres 9.4\r\n\r\n        $ lua\r\n        Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio\r\n        > pgsql = require 'pgsql'\r\n        > conn = pgsql.connectdb('dbname=markus user=markus')\r\n        > res = conn:exec('select * from test01')\r\n        > res:getvalue(1,1)\r\n        1\r\n        > res:getvalue(1,2)\r\n        bla\r\n        > \r\n"}}