0

I have installed ta-lib in my ubuntu 14.04 as mentioned in the official documentation

extract tar.gz
./configure
./make
./make install

It installed ta-lib in /usr/local/include/ta-lib. I then added the header to talib alone #include <ta-lib/ta_libc.h> and compiled the code without error. but when I added the ta-lib sample codes

    #include <ta-lib/ta_libc.h>
    TA_RetCode retCode;
    retCode = TA_Initialize( );
    if( retCode != TA_SUCCESS )
    printf( "Cannot initialize TA-Lib (%d)!\n", retCode );
    else
    {
        printf( "TA-Lib correctly initialized.\n" );

        /* ... other TA-Lib functions can be used here. */

        TA_Shutdown();
    }

it gave an undefined error which I know was due to linking problem in codeblocks. So I manually added ta-lib in project>build options> linker settings>link libraries and -lta-lib to other linker options but now its giving this error

/usr/bin/ld: cannot find -lta-lib
Eka
  • 14,170
  • 38
  • 128
  • 212

1 Answers1

2
./configure
./make
./make install

will not install the package.

./configure
make
sudo make install

will install it. That is probably what you did.

It installed ta-lib in /usr/local/include/ta-lib

Not exactly. It installed the library's header files under /usr/local/include/ta-lib and it installed the static and shared libraries under /usr/local/lib.

I manually added ta-lib in project>build options> linker settings>link libraries and -lta-lib to other linker options

Those are alternative ways of doing the same thing. Both them will cause the option -lta-lib to be passed to the linker, so your linker commandline would show this option twice.

That option directs the linker to search for a shared library called libta-lib.so or, failing that, a static library called libta-lib.a in each of the linker search directories that you have specified, if any, and then in its default search directories.

You have specified no linker search directories, but that is OK, because /usr/local/lib, where the libraries are installed, is one of the linker's default search directories.

The linker nevertheless complains that it cannot find a library for the option -lta-lib because the shared library installed in /usr/local/lib is libta_lib.so and the static library is libta_lib.a. Not libta-lib.{so|a}.

So :-

  • Replace ta-lib with ta_lib in Build options -> Linker settings -> Link libraries
  • Delete -lta-lib from Build options -> Linker settings -> Other linker options
Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
  • Thanks you were right about the `sudo make install` and `ta_lib` now its compiling without any error – Eka Jul 25 '16 at 14:36