[pgrouting-dev] Regarding the generation of .so file for a postgresql function

Hello there,

       I am working on one of my projects which requires the implementation of a function/query which uses data from a postgresql database. To do so I need to generate a "my_function.so" from "my_function.c",which uses cpp functions.I am facing a problem in linking "my_function.c" with the cpp files(where the cpp functions are defined) and generate a "my_function.so" which is used to create a postgresql function.

"my_cpp_header.h":-

#ifndef DIJKSTRA_FUNCTION_H_
#define DIJKSTRA_FUNCTION_H_

#ifdef __cplusplus
extern "C" {
#endif

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path);

#ifdef __cplusplus
}
#endif

#endif

"my_cpp_function.cpp":-

#include "my_cpp_header.h"

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path)
{
      definition of the function(in cpp)
}

I need to generate "my_function.so" from "my_function.c" which uses the above function.

Please help me solving this.

Thanks in advance.

Since this is a matter to do with the operating system, it might help if you stated what machine you where using, what operating systems , which version the compile your using etc.

D..

October 25 2015 7:37 AM, "Sankepally Rohith Reddy" <rohith.reddy@research.iiit.ac.in> wrote:

Hello there,

I am working on one of my projects which requires the implementation of a function/query which uses
data from a postgresql database. To do so I need to generate a "my_function.so" from
"my_function.c",which uses cpp functions.I am facing a problem in linking "my_function.c" with the
cpp files(where the cpp functions are defined) and generate a "my_function.so" which is used to
create a postgresql function.

"my_cpp_header.h":-

#ifndef DIJKSTRA_FUNCTION_H_
#define DIJKSTRA_FUNCTION_H_

#ifdef __cplusplus
extern "C" {
#endif

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path);

#ifdef __cplusplus
}
#endif

#endif

"my_cpp_function.cpp":-

#include "my_cpp_header.h"

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path)
{
definition of the function(in cpp)
}

I need to generate "my_function.so" from "my_function.c" which uses the above function.

Please help me solving this.

Thanks in advance.

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

Also we already do this in the build tree for pgrouting v2.0.0 a good example of this in the tsp algorithm.

git checkout v2.0.0

and look at the CMakeLists.txt files stating at:

CMakeLists.txt
src/CMakeLists.txt
src/tsp/CMakeLists.txt
src/tsp/src/CMakeLists.txt

and look for tsp related lines.

Then in your branch, create a directory tree similar to tsp for your function.

src/myfunc/src etc

and modify the CMakeLists.txt files to deal with your function.

-Steve

On 10/26/2015 9:45 AM, dave.potts@pinan.co.uk wrote:

Since this is a matter to do with the operating system, it might help if you stated what machine you where using, what operating systems , which version the compile your using etc.

D..

October 25 2015 7:37 AM, "Sankepally Rohith Reddy" <rohith.reddy@research.iiit.ac.in> wrote:

Hello there,

I am working on one of my projects which requires the implementation of a function/query which uses
data from a postgresql database. To do so I need to generate a "my_function.so" from
"my_function.c",which uses cpp functions.I am facing a problem in linking "my_function.c" with the
cpp files(where the cpp functions are defined) and generate a "my_function.so" which is used to
create a postgresql function.

"my_cpp_header.h":-

#ifndef DIJKSTRA_FUNCTION_H_
#define DIJKSTRA_FUNCTION_H_

#ifdef __cplusplus
extern "C" {
#endif

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path);

#ifdef __cplusplus
}
#endif

#endif

"my_cpp_function.cpp":-

#include "my_cpp_header.h"

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path)
{
definition of the function(in cpp)
}

I need to generate "my_function.so" from "my_function.c" which uses the above function.

Please help me solving this.

Thanks in advance.

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

Hello Dave,
    Sorry,I forgot to mention the details.

Machine:- Lenovo G510
Operating system:- Linux (Ubuntu 14.04)
gcc and g++ version:- 4.8.4(both)

Thanks in advance.

----- Original Message -----
From: "dave potts" <dave.potts@pinan.co.uk>
To: "pgrouting-dev" <pgrouting-dev@lists.osgeo.org>
Sent: Monday, October 26, 2015 7:15:28 PM
Subject: Re: [pgrouting-dev] Regarding the generation of .so file for a postgresql function

Since this is a matter to do with the operating system, it might help if you stated what machine you where using, what operating systems , which version the compile your using etc.

D..

October 25 2015 7:37 AM, "Sankepally Rohith Reddy" <rohith.reddy@research.iiit.ac.in> wrote:

Hello there,

I am working on one of my projects which requires the implementation of a function/query which uses
data from a postgresql database. To do so I need to generate a "my_function.so" from
"my_function.c",which uses cpp functions.I am facing a problem in linking "my_function.c" with the
cpp files(where the cpp functions are defined) and generate a "my_function.so" which is used to
create a postgresql function.

"my_cpp_header.h":-

#ifndef DIJKSTRA_FUNCTION_H_
#define DIJKSTRA_FUNCTION_H_

#ifdef __cplusplus
extern "C" {
#endif

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path);

#ifdef __cplusplus
}
#endif

#endif

"my_cpp_function.cpp":-

#include "my_cpp_header.h"

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path)
{
definition of the function(in cpp)
}

I need to generate "my_function.so" from "my_function.c" which uses the above function.

Please help me solving this.

Thanks in advance.

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

Hey Steve,
     I've gone through the CMakeLists.txt files you stated and they were very helpful.I modified them accordingly.Finally my function worked :slight_smile:
     Thanks a lot.

----- Original Message -----
From: "Stephen Woodbridge" <woodbri@swoodbridge.com>
To: "pgrouting-dev" <pgrouting-dev@lists.osgeo.org>
Sent: Monday, October 26, 2015 7:38:36 PM
Subject: Re: [pgrouting-dev] Regarding the generation of .so file for a postgresql function

Also we already do this in the build tree for pgrouting v2.0.0 a good
example of this in the tsp algorithm.

git checkout v2.0.0

and look at the CMakeLists.txt files stating at:

CMakeLists.txt
src/CMakeLists.txt
src/tsp/CMakeLists.txt
src/tsp/src/CMakeLists.txt

and look for tsp related lines.

Then in your branch, create a directory tree similar to tsp for your
function.

src/myfunc/src etc

and modify the CMakeLists.txt files to deal with your function.

-Steve

On 10/26/2015 9:45 AM, dave.potts@pinan.co.uk wrote:

Since this is a matter to do with the operating system, it might help if you stated what machine you where using, what operating systems , which version the compile your using etc.

D..

October 25 2015 7:37 AM, "Sankepally Rohith Reddy" <rohith.reddy@research.iiit.ac.in> wrote:

Hello there,

I am working on one of my projects which requires the implementation of a function/query which uses
data from a postgresql database. To do so I need to generate a "my_function.so" from
"my_function.c",which uses cpp functions.I am facing a problem in linking "my_function.c" with the
cpp files(where the cpp functions are defined) and generate a "my_function.so" which is used to
create a postgresql function.

"my_cpp_header.h":-

#ifndef DIJKSTRA_FUNCTION_H_
#define DIJKSTRA_FUNCTION_H_

#ifdef __cplusplus
extern "C" {
#endif

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path);

#ifdef __cplusplus
}
#endif

#endif

"my_cpp_function.cpp":-

#include "my_cpp_header.h"

int compute_dijkstra(int source,int target,Edge *edges,int num_vertices,int num_edges,Edge **path)
{
definition of the function(in cpp)
}

I need to generate "my_function.so" from "my_function.c" which uses the above function.

Please help me solving this.

Thanks in advance.

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev

_______________________________________________
pgrouting-dev mailing list
pgrouting-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-dev