C++ newbie gets linking error

Hi,
I am writing my first C++ programs (been a SQL/DB programmer for last 10 years) on Sun Solaris. Here is my source code:
#include <list>
#include <string>
#include <iostream.h>
using namespace std; // You must use this to include STL!
int main()
// Create list instances
list<int> list1; // Empty list
size_t n = 10;
double val = 3.14;
list<double> list2(n, val); // Create n copies of val
list<double> list3(list2); // Create a copy of list2
cout << "Size of list1 " << list1.size() << endl;
cout << "Size of list2 " << list2.size() << endl;
cout << "Size of list3 " << list3.size() << endl;
// We iterate over the elements of list 3 and print its elements
// Create list iterator
list<double>::const_iterator i;
// Print every character in the list
for (i = list2.begin(); i != list2.end(); ++i)
cout << *i << ",";
and getting the following linker error:
/SUNWspro/9.0/exec/SUNWspro/bin/CC -o test test.cpp
Undefined first referenced
symbol in file
std::bad_alloc::bad_alloc() test.o
void*operator new(unsigned,void*) test.o
ld: fatal: Symbol referencing errors. No output written to test
I have heard of Solaris C++ compilers having problem with the use of templates..... is this the problem here or am I just missing some arguments/libraries?
Thx in advance!

In the interest of keeping code examples short and simple, textbook authors do things in their code examples that are not suitable for real-world applications. Apart from "using namespace std", you find global variables and functions with short names, and no attention paid to error detection or recovery. (They also use more explanatory comments in the code than a real-world program should have.)
That's OK when you are illustrating particular language points. You want to highlight the point, and not have a lot of distractions. But in my view, not enough authors go on to explain good programming practice, and show realistic examples.
For the case in point, the Standard Library declares thousands of names. They are in namespace std to help avoid collisions with user-defined names. Once you put "using namespace std" into your code, you import all of those names into the global namespace, creating opportunities not only for compiler complaints due to name collisions, but for subtle errors involving binding symbols to the standard library that you expected to refer to your own definitions.
I never write "using namespace std" in real code. I sometimes use it when creating tiny test cases for bug reports. But as you saw in my earlier comments, the difference in the sample program between a dangerous programming practice and a much better programming practice was one line of code!

Similar Messages

  • Another java newbie question:  "Link errors"

    In the environments I've attempted compiling in, it seems that there is a just-in-time default, which means that any missing classes are not found until run time.
    Is there any way to to run javac so that what we used to call "link errors" will be displayed at compile time?

    Java has no .h files, so it shouldn't compile at all if a class is missing, unless:
    Someone compiles class Library, they have class Extension available
    They give you Library
    You compile, javac sees theat "Library" exists and checks no further
    At run time, you get errors about Library needs missing class "Extension"
    What class is missing anyhow?

  • Getting linker error in Visual studio while trying to use class ActiveSelectionObserver

    I am trying to implement a selection observer. I am using public specifier to derive from class ActiveSelectionObserver and have included the header file SelectionObserver.h.
    But I am getting the below error from linker while trying to do that.
    Below is the my code:
    class CSDTSelectionObserverImpl : public ActiveSelectionObserver
    /* some code here**/
    Below is the linker error:
    CSDTSelectionObserverImpl.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl ActiveSelectionObserver::ActiveSelectionObserver(class IPMUnknown *,class IDType<struct PMIID_tag>)" (__imp_??0ActiveSelectionObserver@@QEAA@PEAVIPMUnknown@@V?$IDType@UPMIID_tag@@@@@Z) referenced in function "public: __cdecl CSDTSelectionObserverImpl::CSDTSelectionObserverImpl(class IPMUnknown *)" (??0CSDTSelectionObserverImpl@@QEAA@PEAVIPMUnknown@@@Z)

    Thanks Markus, this resolved the issue.
    I Included below in properties> linker>input>Additional dependencies
    $(ID_SDK_DIR)\build\win\objdx64\WidgetBin.lib
    But is there some documentation to get this information? as what all .lib are needed for a particular class etc?

  • Can not Package file. Getting Link Error.

    My document has no Errors reported, and everything is accounted for.
    When I go to Package, I get this error.  https://www.dropbox.com/s/nkj0e4tzsr2ue25/Screenshot%202013-12-23%2011.08.52.png
    How can I troubleshoot this file when there is no specific indication of the error?
    When I package the file I'm not including fonts, just image links.
    I'm running InDesign CC.
    Thanks.

    Hi. Thanks for answering.  I checked all the links.  Only one file had an unusual character, and that has been corrected.  No other unusual characters, other than hyphen or underscore.
    Just tried to repackage, and still getting the same error.
    I wish if there was an error like this InDesign could log the error file it's having trouble with.
    Any other suggestions on how to trouble shoot this file for packaging?
    Thanks.

  • Getting Linker errors while porting InDesign CC plugin code to InDesign CC 2014

    Hello,
    I am getting following linker errors during porting of plugin code from InDesign CC to InDesign CC 2014
    > PlugInStatics.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)
    > PlugInStatics.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat@system@boost@@YAXXZ)
    I am using following environment :
    OS : Windows 7 SP1 (64bit)
    Visual Studio : VS 2013 with platform tool set = Visual Studio 2010 (v100)
    InDesign SDK : InDesign CC 2014 plugin SDK (070)
    Boost Libraries : 1.55
    I have added external boost library paths in visual studio -> Linker properties -> Additional Library paths, still above linker errors persists, can someone help ?
    Thanks,
    -Harsh.

    Hello Bartek,
    Your answer resolved similar linker errors I faced while porting InDesign plug-ins from CC to CC 2014.
    I added the macro - BOOST_SYSTEM_NO_DEPRECATED to the Preprocessor Definitions in VS 2012 SP4 and the build succeeded.
    The second option of adding the macros - BOOST_ALL_DYN_LINK;BOOST_REGEX_USE_CPP_LOCALE;BOOST_REGEX_RECURSIVE;BOOST_HAS_ICU=1;BOOST_ FILESYSTEM_VERSION=3;BOOST_CHRONO_HEADER_ONLY;BOOST_SIGNALS_NO_DEPRECATION_WARNING; did not work for me.
    Can you explain why this linker error showed up? And how the macro solved it?
    Thanks,
    Vijayasri

  • Getting Linker Error in VC for Pro*C Compiled file

    Although i've included the orasql8.lib and orasqx8.lib , even
    i've tried it out with sqllib18.lib but still getting the same
    error.....if anyone here can solve out the problem will be great
    for me.....please help ASAP.....
    Pro*C is compiling the .pc file to .cpp but error is coming
    while liking in vc++...
    VC6.0 and Pro*C Ver 8.1.6.0.0
    Linking...
    Oracle.obj : error LNK2001: unresolved external symbol "void
    __cdecl sqlcxt(void * *,unsigned long *,struct sqlexd *,struct
    sqlcxp const *)" (?sqlcxt@@YAXPAPAXPAKPAUsqlexd@@PBUsqlcxp@@@Z)
    Debug/Access.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    Access.exe - 2 error(s), 0 warning(s)

    I am having the same problem. COuld anybody help?

  • Newbie getting snytax error

    I'm trying to create a table with a floating amount of columns, I create the table fine with 3 fixed columns but when I try to add more columns I get a syntax error. Since I'm new to this and learning as I go can anyone point out some errors I'm making.
    Thanks
    Jim
    error message:
    Syntax error or access violation: You have an error in your SQL syntax near 'select your GENDER:BLOB NOT NULL' at line 1
    Closeing connection
    Using MySql:
    stmt = con.createStatement();
          stmt.executeUpdate( "CREATE TABLE TestDataBase1("  +
             "Respondent INTEGER      NOT NULL, "    +
             "Date       VARCHAR (10) NOT NULL, "    +
             "Time       VARCHAR (10) NOT NULL, "    +
             "PRIMARY KEY( Respondent )"                  +
         for( int i = 1; i <= questionText.length; i++ ){
              stmt.executeUpdate ("ALTER TABLE TestDataBase1 ADD COLUMN "+getColumnName(i)+" BLOB NOT NULL");
    //.... snip
    // return the question that will be the column header
    public String getColumnName( int i ){
        return questionText;

    Hey, Thanks for the reply.
    I was pictureing it like this but I can't envision
    your description
    |--------|--------|-------|-------|--------------------
    |Resp |Date |Time | Q1 |Q2 etc...
    | 1 | blah |blah | yes |Male
    | 2 | blah |blah | no |Female
    | | | | |
    ||--------|--------|-------|-------|--------------------
    |Resp |Date |Time | Q1 |Q2 etc...
    | 1 | blah |blah | yes |Male
    | 2 | blah |blah | no |Female
    | | | | |
    |
    would become
    Respondents table
    |--------|--------|-------|-------|--------------------
    |Resp |Date |Time | \\\
    | 1 | blah |blah |
    | 2 | blah |blah |
    | | | |
    answers table
    |--------|--------|-------|-------|--------------------
    |Resp | Question | answer
    | 1 | 1 | Male
    | 1 | 2 | no
    | 2 | 1 | Male
    | 2 | 2 | yes
    This makes it much easier to query results, to get the response to the first 5 questions would be.
    select * from answers where question between 1 and 5
    under your design it would be UGLY.
    This model is easily extended to multiple tests simply by adding a column for the test ID to the respondent table.

  • Linker Error while building files refering to NI-DAQ API

    Software: MATLAB 5.3
    O/S : Windows 98
    C Compiler : Microsoft VC++ 6.0
    We are trying to make an executable of an Application involving both of MatLab and C Files
    The file SCANsingleBufSync2.c is C program calling National Instruments NI-DAQ API's. This C program is called by displayCnt3.m,a MatLab Program. Both of the files are individually compiled using
    mcc -x SCANsingleBufSync2.c, ...
    That works fine.
    When trying to make a build , using
    mcc -B sgl displayCnt3 SCANsingleBufSync2.c
    it is throwing the following error.(pl. refer section at end)
    Basically it is not able to do Link. The MatLab path has been set to look into the NI-DAQ .dlls
    C:\Program Files\National Instruments\Ni-daq\Includes and
    C:\Program Files\National Instruments\Ni-daq\Lib
    Also the Windows path has been set to the above two directories through the autoexec.bat.
    Suggestions Please,
    Thanks in advace,
    MOHANDAS
    � mcc -B sgl displayCnt3 SCANsingleBufSync2.c
    SCANsingleBufSync2.obj : error LNK2001: unresolved external symbol _DAQ_VScale@40
    SCANsingleBufSync2.obj : error LNK2001: unresolved external symbol _SCAN_Demux@16
    SCANsingleBufSync2.obj : error LNK2001: unresolved external symbol _SCAN_Op@40
    SCANsingleBufSync2.obj : error LNK2001: unresolved external symbol _NIDAQErrorHandler@12
    SCANsingleBufSync2.obj : error LNK2001: unresolved external symbol _Timeout_Config@8
    displayCnt3.obj : error LNK2001: unresolved external symbol _MdisplayCnt3_SCANsingleBufSync2
    displayCnt3.exe : fatal error LNK1120: 6 unresolved externals
    MBUILD.BAT: Link of 'displayCnt3.exe' failed.
    mcc -B sgl displayCnt counter.c
    counter.obj : error LNK2001: unresolved external symbol _Select_Signal@16
    counter.obj : error LNK2001: unresolved external symbol _GPCTR_Change_Parameter@16
    counter.obj : error LNK2001: unresolved external symbol _GPCTR_Set_Application@12
    counter.obj : error LNK2001: unresolved external symbol _NIDAQErrorHandler@12
    counter.obj : error LNK2001: unresolved external symbol _GPCTR_Control@12
    counter.obj : error LNK2001: unresolved external symbol _GPCTR_Config_Buffer@20
    counter.obj : error LNK2001: unresolved external symbol _Set_DAQ_Device_Info@12
    counter.obj : error LNK2001: unresolved external symbol _NIDAQYield@4
    counter.obj : error LNK2001: unresolved external symbol _GPCTR_Read_Buffer@36
    displayCnt.exe : fatal error LNK1120: 9 unresolved externals
    MBUILD.BAT: Link of 'displayCnt.exe' failed.

    I'm not very familiar with MATLAB, but you are getting link errors most likely because you aren't linking in the .LIB files for NI-DAQ properly. They are nidaq32.lib and nidex32.lib in the NI-DAQ\lib directory. They need to be linked in with the code to resolve these symbols.
    Best Regards,
    Chris Matthews
    National Instruments

  • Link errors for NI-MAQdx examples

    I’m getting link errors while debug compiling for all of the NIMAQdx examples.  There are three of them and they start with Undefined symbol, then ‘_UPLIBBreadpointWithElab@16’ referenced in the .lib file.  Using version CVI2013 and NI-MAQdx 4.2  Any suggestions?  Thanks.
    snelson

    Hi Andy,
    It's occurring on all of the examples IMAQdx examples.  I have a 32-bit PC, but tried it also on a 64-bit with the same linking errors.  I'm compiling in debug, but same errors during release version.  I think I'm including all of the appropriate files.  Attached is a screen shot.
    Thanks,
    snelson
    snelson
    Attachments:
    screen shot.jpg ‏191 KB

  • Linker errors when linking OCCI 10.1.0  statically on RH AS 3.0 platform

    Hello All,
    I was trying to build an OCCI program on a Red Hat AS 3.0 Update 4 Platform, statically linking to OCCI libraries of Oracle 10.1.0 version. The g++ compiler version is 3.2.3.
    The Makefile and the errors that got generated is mentioned below. However, I could able to build the program when linking through shared library version of OCCI. My requirement is to build the program statically.
    I had been stuck up with this for almost a week and tried checking the previous postings in the forums/newsgroups, but not of much help. I added the following libraries :
    -lnbeq10 -lnhost10 -lnus10 -lnldap10 -lldapclnt10\
    -lnsslb10 -lntcp10 -lntcps10 -lnsslb10 -lntcp10 -lntns10
    to the Makefile, based on somebody's posting in OCI/OCCI forum. If I didn't provide
    -lpthread I get linker errors in pthread_xxx functions.
    Any help/pointers on this would be really appreciated.
    Makefile (static link)
    ======
    CXX=/usr/bin/g++
    ORA_HOME=/u01/app/oracle/product/10.1.0
    ifndef CXXFLAGS
    # Define C++ compiler flags to locate third-party header files as well as
    # any other options you may want.
    CXXFLAGS=-I${ORA_HOME}/rdbms/demo \
    -I${ORA_HOME}/rdbms/public \
    -I${ORA_HOME}/plsql/public \
    -I${ORA_HOME}/network/public
    endif
    # Include any header files in the current directoryj
    CXXFLAGS:=$(CXXFLAGS) -I . -g -static
    ifndef LDFLAGS
    # Define link paths for Oracle libraries.
    LDFLAGS=-L${ORA_HOME}/lib/ -L${ORA_HOME}/rdbms/lib/
    endif
    LIBS=-locci10 -lclntst10 -lnsl -ldl -lm \
    -lnbeq10 -lnhost10 -lnus10 -lnldap10 -lldapclnt10\
    -lnsslb10 -lntcp10 -lntcps10 -lnsslb10 -lntcp10 -lntns10 -lpthread
    #LIBS=${ORA_HOME}/lib/libocci10.a ${ORA_HOME}/lib/libclntst10.a -lpthread -ldl
    OCCIPROG=SCDBUtilTest
    OCCIOBJ=SCDBUtil.o SCDBUtilTest.o
    debug: ${OCCIPROG}
    ${OCCIPROG}: ${OCCIOBJ}
    ${CXX} ${CXXFLAGS} -o $@ ${OCCIOBJ} ${LDFLAGS} ${LIBS}
    clean:
    -rm -f $(OCCIPROG) $(OCCIOBJ)
    When ran make, below is the output generated.
    /usr/bin/g++ -I/u01/app/oracle/product/10.1.0/rdbms/demo -I/u01/app/oracle/product/10.1.0/rdbms/public -I/u01/app/oracle/product/10.1.0/plsql/public -I/u01/app/oracle/product/10.1.0/network/public -I . -g -static -c -o SCDBUtil.o SCDBUtil.cpp
    /usr/bin/g++ -I/u01/app/oracle/product/10.1.0/rdbms/demo -I/u01/app/oracle/product/10.1.0/rdbms/public -I/u01/app/oracle/product/10.1.0/plsql/public -I/u01/app/oracle/product/10.1.0/network/public -I . -g -static -c -o SCDBUtilTest.o SCDBUtilTest.cpp
    /usr/bin/g++ -I/u01/app/oracle/product/10.1.0/rdbms/demo -I/u01/app/oracle/product/10.1.0/rdbms/public -I/u01/app/oracle/product/10.1.0/plsql/public -I/u01/app/oracle/product/10.1.0/network/public -I . -g -static -o SCDBUtilTest SCDBUtil.o SCDBUtilTest.o -L/u01/app/oracle/product/10.1.0/lib/ -L/u01/app/oracle/product/10.1.0/rdbms/lib/ -locci10 -lclntst10 -lnsl -ldl -lm -lnbeq10 -lnhost10 -lnus10 -lnldap10 -lldapclnt10 -lnsslb10 -lntcp10 -lntcps10 -lnsslb10 -lntcp10 -lntns10 -lpthread
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sqmul.o)(.text+0xab): In function `sqmul_dlopen':
    : Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sntp.o)(.text+0x1089): In function `sntpcall':
    : Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sntp.o)(.text+0x10a1): In function `sntpcall':
    : Using 'endgrent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sntp.o)(.text+0xfa1): In function `sntpcall':
    : Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(si.o)(.text+0x14f): In function `sigunmu':
    : Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sniq.o)(.text+0x224): In function `snigun':
    : Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(snlpc.o)(.text+0x1427): In function `snlpcgthstbyad':
    : Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(slputcp.o)(.text+0x245): In function `slputcpsockaddr':
    : Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sgslun.o)(.text+0x2ef0): In function `sgslunGetHostName':
    : Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(snlpc.o)(.text+0xe90): In function `snlpcgthstent':
    : Using 'gethostent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(snlpc.o)(.text+0x1945): In function `snlpcgtsrvbynm':
    : Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(snlpc.o)(.text+0x1b8b): In function `snlpcgtsrvbypt':
    : Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(snlpc.o)(.text+0x1702): In function `snlpcgtsrvent':
    : Using 'getservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiStatementImpl.o)(.text+0x6ffb): In function `oracle::occi::StatementImpl::getObject(unsigned int)':
    : undefined reference to `OCIPAnyDataSetFlag'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiResultSetImpl.o)(.text+0xf99): In function `oracle::occi::ResultSetImpl::getBFloat(unsigned int)':
    : undefined reference to `lfpinit'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiResultSetImpl.o)(.text+0x10d9): In function `oracle::occi::ResultSetImpl::getBDouble(unsigned int)':
    : undefined reference to `lfpinit'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiResultSetImpl.o)(.text+0x1ca8): In function `oracle::occi::ResultSetImpl::getObject(unsigned int)':
    : undefined reference to `OCIPAnyDataSetFlag'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiResultSetImpl.o)(.text+0x48b6): In function `oracle::occi::ResultSetImpl::defineConvertBFloat(oracle::occi::ResultSetImpl::Define*, float*, unsigned int*, int)':
    : undefined reference to `lfpinit'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiResultSetImpl.o)(.text+0x49e2): In function `oracle::occi::ResultSetImpl::defineConvertBDouble(oracle::occi::ResultSetImpl::Define*, double*, unsigned int*, int)':
    : undefined reference to `lfpinit'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiTimestamp.o)(.text+0x1aa): In function `oracle::occi::Timestamp::Timestamp(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
    : undefined reference to `OCIPGetTZI'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiTimestamp.o)(.text+0x256): In function `oracle::occi::Timestamp::Timestamp(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
    : undefined reference to `OCIPGetTZI'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiTimestamp.o)(.text+0x302): In function `oracle::occi::Timestamp::Timestamp(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, std::basic_string<unsigned short, oracle::occi::utext_char_traits, std::allocator<unsigned short> > const&)':
    : undefined reference to `OCIPGetTZI'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiTimestamp.o)(.text+0x3be): In function `oracle::occi::Timestamp::Timestamp(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, std::basic_string<unsigned short, oracle::occi::utext_char_traits, std::allocator<unsigned short> > const&)':
    : undefined reference to `OCIPGetTZI'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiTimestamp.o)(.text+0x48a): In function `oracle::occi::Timestamp::do_TimestampConstruct(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, void*)':
    : undefined reference to `OCIPGetTZI'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiTimestamp.o)(.text+0xb42): more undefined references to `OCIPGetTZI' follow
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiSQLExceptionImpl.o)(.text+0x91): In function `oracle::occi::SQLExceptionImpl::getNLSMessage(oracle::occi::Environment*) const':
    : undefined reference to `OCIPGetErrorMessageNLS'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiSQLExceptionImpl.o)(.text+0x15b): In function `oracle::occi::SQLExceptionImpl::getNLSUStringMessage(oracle::occi::Environment*) const':
    : undefined reference to `OCIPGetErrorMessageNLS'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x56): In function `oracle::occi::AnyDataImpl::AnyDataImpl(oracle::occi::Connection const*, OCIAnyData*, bool)':
    : undefined reference to `OCIPAnyDataSetUCIOptMode'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x156): In function `oracle::occi::AnyDataImpl::AnyDataImpl(oracle::occi::Connection const*, OCIAnyData*, bool)':
    : undefined reference to `OCIPAnyDataSetUCIOptMode'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x3ae): In function `oracle::occi::AnyDataImpl::AnyDataImpl(oracle::occi::AnyDataCtx const*)':
    : undefined reference to `OCIPAnyDataSetUCIOptMode'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x4e6): In function `oracle::occi::AnyDataImpl::AnyDataImpl(oracle::occi::AnyDataCtx const*)':
    : undefined reference to `OCIPAnyDataSetUCIOptMode'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x780): In function `oracle::occi::AnyDataImpl::setNull()':
    : undefined reference to `OCIPAnyDataSetNull'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x1cc5): In function `oracle::occi::AnyDataImpl::setObject(oracle::occi::PObject const*)':
    : undefined reference to `OCIPAnyDataSetFlag'
    /u01/app/oracle/product/10.1.0/lib//libocci10.a(occiAnyDataImpl.o)(.text+0x2d6f): In function `oracle::occi::AnyDataImpl::getAsObject() const':
    : undefined reference to `OCIPAnyDataSetFlag'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstclo.o)(.text+0x39): In function `lstclo':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstclo.o)(.text+0x52): In function `lstclo':
    : undefined reference to `__ctype_tolower'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstclo.o)(.text+0x6f): In function `lstclo':
    : undefined reference to `__ctype_tolower'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstmclo.o)(.text+0x46): In function `lstmclo':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstmclo.o)(.text+0x5f): In function `lstmclo':
    : undefined reference to `__ctype_tolower'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstmclo.o)(.text+0x7c): In function `lstmclo':
    : undefined reference to `__ctype_tolower'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lxhcnv.o)(.text+0x366): In function `lxhcnv':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lxpname.o)(.text+0xc5): In function `lxpname':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(sl.o)(.text+0x405): In function `sltln':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kge.o)(.text+0x2b19): In function `kgespf':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kge.o)(.text+0x2d12): In function `kgespf':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kgh.o)(.text+0x10d48): more undefined references to `__ctype_b' follow
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kpuini.o)(.text+0x1d70): In function `kpufhndl0':
    : undefined reference to `wtcsrfre'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kpuini.o)(.text+0x7e00): In function `kpuinit0':
    : undefined reference to `wtcsrin'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lcvb24.o)(.text+0x45): In function `lcvb24':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lcvb24.o)(.text+0x9a): In function `lcvb24':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lcvb2w.o)(.text+0x45): In function `lcvb2w':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lcvb2w.o)(.text+0x9a): In function `lcvb2w':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lpu.o)(.text+0x1c5): In function `lpuparse':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lpu.o)(.text+0xf62): more undefined references to `__ctype_b' follow
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstlo.o)(.text+0x44): In function `lstlo':
    : undefined reference to `__ctype_tolower'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstmup.o)(.text+0x43): In function `lstmup':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstup.o)(.text+0x28): In function `lstup':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstup.o)(.text+0x44): In function `lstup':
    : undefined reference to `__ctype_toupper'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lsxv.o)(.text+0x54f5): In function `LsxvParseDecimal':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lsxv.o)(.text+0x6da8): In function `LsxValidateBinary':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lsxv.o)(.text+0x7710): In function `LsxValidateLong':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lsxv.o)(.text+0xb274): In function `LsxvIsLanguage':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lsxv.o)(.text+0xb316): In function `LsxvIsLanguage':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lsxv.o)(.text+0xb3ac): more undefined references to `__ctype_b' follow
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kpucc.o)(.text+0x271): In function `kpuccCacheErr':
    : undefined reference to `wtcLerr'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kpucc.o)(.text+0x2a6): In function `kpuccMainErr':
    : undefined reference to `wtcMerr'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kpucc.o)(.text+0x2e1): In function `kpuccGoRemote':
    : undefined reference to `wtclkm'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(kpucc.o)(.text+0x326): In function `kpuccGetStats':
    : undefined reference to `wtcstu'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lpxbuf.o)(.text+0x2a4f): In function `LpxbufSingleProcess':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(lstmlo.o)(.text+0x43): In function `lstmlo':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(nldt.o)(.text+0x9a1): In function `nldtstr2lv':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(nlfi.o)(.text+0x42f): In function `nlfifpf':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(nlfi.o)(.text+0x462): In function `nlfifpf':
    : undefined reference to `__ctype_b'
    /u01/app/oracle/product/10.1.0/lib//libclntst10.a(nlfi.o)(.text+0x4d4): more undefined references to `__ctype_b' follow
    collect2: ld returned 1 exit status
    make: *** [SCDBUtilTest] Error 1
    Thanks & Regards,
    Karthik D

    Hi ,
    Oh! Anyway, thanks for the information. However, the glibc version I use is glibc-2.3.2-95.30.
    There is a bit of story behind the reason we tried to use static linking. Actually, the application around which we use to develop solutions supports only Oracle 9i. We were developing some components using the C++ SDK provided by application vendor and that components need some information from DB for processing. So, we needed to write a DB class to do that. Since, we found Oracle supports C++ DB interface(OCCI), we thought to use that.
    We had to use RH AS 3.0 platform and the gcc compiler 3.2.x+ for compiling our component code. But Oracle 9i OCCI code doesn't get compiled with gcc/g++ 3.2.x+ compilers. So, we planned to use Oracle 10g OCCI libraries for building the DB class and link it to the custom component we had developed.
    In the run-time environment, we had to install both Oracle 9i clients and Oracle 10g clients since the app requires Oracle 9i and the custom component requires Oracle 10g. We did some kind of tweaking (by providing symbolic links to Oracle 10g OCCI libraries from Oracle 9i client directory) so that both the app and the component gets started.
    I know this is not a good idea. But we didn't want to spend much time on this at that time since we were doing a proof-of-concept. Later, we thought what could be done. We thought ,first we can try lthe custom component linked to static library version of OCCI. That's the reason we tried of static linking.
    The other option is to use OCI interface. But this is a bit of work since we need to write lot of wrapper methods to handle intricacies with OCI and OCI code is cumbersome compared to OCCI.
    Hope now you could have got the problem, I am talking about. Any other better ways?
    Thanks
    Karthik

  • Linking errors (LNK2001) for NIDAQ functions such as _NIDAQErrorHandler@12

    I am getting linking errors (LNK2001) when I try to build any of the C++ EXAMPLES that came with my NI PCI6052E (for instance AOonePoint.C). I think I've included all the necessary libs in my project but I can't get past the linker (I'm using MS VC++ 6.0) and the actual errors read something like:
    Linking...
    AOonePoint.obj : error LNK2001: unresolved external symbol _NIDAQErrorHandler@12
    AOonePoint.obj : error LNK2001: unresolved external symbol _AO_VWrite@16
    AOonePoint.obj : error LNK2001: unresolved external symbol _NIDAQWaitForKey@8
    Debug/AOonePoint.exe : fatal error LNK1120: 3 unresolved externals
    Error executing link.exe.
    thanks for your help!

    You will need to add two library files to your project. To do this, select 'Project' from VC++ menu bar, then 'Add to Project' >> Files. Then follow this path to the files.
    /Program Files/National Instruments/NI-DAQ/Lib
    You will have to change 'Files of Type' to 'All Files.'
    The two files to add are nidaq32.lib and nidex32.lib.
    Brian

  • Link Error ...HELLLPPP

    Folk
    I try to create a dll and call within my java code....but I get link error when I try to build my library...
    here is how I call the library:
    .java file
    qcSys(command, byteImgLocal);
    public native void qcSys(String command, byte[] byteImgLocal);
    static
    System.loadLibrary("qcSys");
    .h file machine genrated
    JNIEXPORT void JNICALL Java_SrDesign_qcSys(JNIEnv *, jobject, jstring, jbyteArray);
    .c file
    #include <StubPreamble.h>
    #include <stdio.h>
    #include "SrDesign.h"
    void SrDesign_qcSys(struct HSrDesign *this,
    struct Hjava_lang_String command, HArrayOfByte byteImage)
    char *QCimage = unhand(byteImage)->body;
    int length = obj_length(byteImage);
    FILE *fp;
    fp = popen(makeCString(command),"r");
    fgets(QCimage, length, fp);
    return;
    now when I build the project in MVC++ 6 on windows 2000 I get bellow messages
    warnning on line fp=popen(makeCString (command), "r");
    1. 'popen' undefined; assuming extern returning int
    2. 'makeCString' undefined; assuming extern retruning int
    3. '=' : 'struct_iobuf *' differs in levels of indirection from int
    linking...
    qcSys.obj : error LNK2001 : unresolved external symbold _popen
    qcSys.obj : error LNK2001 : unresolved external sysmbol _makeCString
    Error executing link.exe
    can somebody helllllp me please! I'm not familiar with MVC++

    now when I build the project in MVC++ 6 on windows
    2000 I get bellow messages
    warnning on line fp=popen(makeCString (command),
    "r");When you get warning you better pay attention to them.
    1. 'popen' undefined; assuming extern returning intThis says that the compiler does not know what function 'popen' is.
    Given that the method looks a lot like 'fopen' I question where you got it from.
    Note that even though the compiler has no idea what you are talking about it has no problem compiling with a best guess.
    2. 'makeCString' undefined; assuming extern retruning
    intAgain the function is not defined. You need to figure out what it is.
    3. '=' : 'struct_iobuf *' differs in levels of
    indirection from int
    linking...Bad, bad, bad idea to ignore any error that has anything to do with pointers.
    Best guess you are not accessing this correctly.
    qcSys.obj : error LNK2001 : unresolved external
    symbold _popenEither you misspelled the name or you need to find your library that has this (it is not a C/C++ method.)
    qcSys.obj : error LNK2001 : unresolved external
    sysmbol _makeCString
    Error executing link.exe
    Same thing as above.

  • Link Error with Sample on Solaris

    I am getting linking error when compiling the sample for XML C++ Parser, help anyone ?
    make SAXSample
    gcc -o SAXSample -I../include SAXSample.cpp -L../lib -lxml8 -lxmlc8 -lcore8 -lnls8 -lcore8 -lnls8 -lcore8 -lnsl -lsocket
    Undefined first referenced
    symbol in file
    cout /var/tmp/cczSDNUP.o
    XMLParser::xmlterm(void) /var/tmp/cczSDNUP.o
    XMLParser::xmlinit(unsigned char *, void (*)(void *, unsigned char const *, unsigned int), void *, xmlsaxcb *, void *, unsigned char *)/var/tmp/cczSDNUP.o
    ostream::operator<<(char const *) /var/tmp/cczSDNUP.o
    ostream::operator<<(unsigned int) /var/tmp/cczSDNUP.o
    XMLParser::xmlparse(unsigned char *, unsigned char *, unsigned int)/var/tmp/cczSDNUP.o
    ostream::write(unsigned char const *, int)/var/tmp/cczSDNUP.o
    ostream::flush(void) /var/tmp/cczSDNUP.o
    ld: fatal: Symbol referencing errors. No output written to SAXSample
    collect2: ld returned 1 exit status
    *** Error code 1
    make: Fatal error: Command failed for target `SAXSample'
    null

    I am getting this problem as well. I see it was also reported by 2 other people earler. Has anyone resolved this yet? I also have these unresolved external problems when using the C V1 XML parser. It is almost as if the libs downloaded are for a different version of Solaris and not recognized by the newly compiled objects. I have tried a number of things to resolve this without success.
    Any help would be greatly appreciated.
    Thanks
    Julie Bartlett
    null

  • C Code NI-VISA linker error

    I wrote the following C command to pass SCPI commands to Rohde&Schwarz FSL
    #define NIVISA_PXI
    #include <visa.h>
    #define MAX_CNT 200
    int main(void)
    ViStatus status; /* For checking errors */
    ViSession defaultRM, instr; /* Communication channels */
    ViUInt32 retCount; /* Return count from string I/O */
    ViChar buffer[MAX_CNT]; /* Buffer for string I/O */
    status = viOpenDefaultRM(&defaultRM);
    if (status < VI_SUCCESS)
    return -1;
    status = viWrite(instr, "*RST", 6, &retCount);
    status = viClose(instr);
    status = viClose(defaultRM);
    return 0;
    I am getting linker errors.   [Linker error] undefined reference to `viOpenDefaultRM@4' 
    I use Bloodshed Dev C++ . I have included the header files from the VXIPNP folder to the include folder od Dev C++. It had 11 files.it had 4 header files visa.h, visatype.h, vpptype.h and rsfsp.h
    Do i need to install any header file or libraries? Please help, this is the first time I am using VISA.H 
    Solved!
    Go to Solution.

    [root@localhost raavan]# gcc main.c -L /usr/local/lib/libvisa.so
    /tmp/ccKHyQta.o: In function `sendscpi':
    main.c: (.text+0x2e): undefined reference to `viWrite'
    /tmp/ccKHyQta.o: In function `main':
    main.c: (.text+0x52): undefined reference to `viOpenDefaultRM'
    main.c: (.text+0x99): undefined reference to `viOpen'
    main.c: (.text+0xbb): undefined reference to `viSetAttribute'
    main.c: (.text+0xd9): undefined reference to `viClose'
    main.c: (.text+0xeb): undefined reference to `viClose'
    collect2: ld returned 1 exit status
    contents of main.c are:
     #include "visa.h"
    #include "stdio.h"
    #include "string.h"
    #define MAX_CNT 200
    char scpi[50]; /*To store the SCPI commands*/
    ViStatus status; /* For checking errors */
    ViSession defaultRM, instr; /* Communication channels */
    ViUInt32 retCount; /* Return count from string I/O */
    ViChar buffer[MAX_CNT]; /* Buffer for string I/O */
    void sendscpi (char *s)  
         status = viWrite(instr, (ViBuf)s, strlen (s), &retCount);
    int main(void)
    /* Begin by initializing the system*/
    status = viOpenDefaultRM(&defaultRM);
    if (status < VI_SUCCESS) {
    return -1;
    /* Open communication with TCPIP Device at Primary Addr FSL (192.168.186.107)*/
    status = viOpen(defaultRM, "192.168.186.107", VI_NULL, VI_NULL,&instr);
    /* Set the timeout for message-based communication*/
    status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 5000);
    /* Send SCPI commands for the test case */
    sendscpi ("*RST" ) ;
    /* Close down the system */
    status = viClose(instr);
    status = viClose(defaultRM);
    return 0;
    Please help!
    Message Edited by rohit_rs on 03-12-2009 07:04 AM
    Message Edited by rohit_rs on 03-12-2009 07:04 AM

  • Linking error - JNI code

    Hi
    I am new to JNI.
    I am getting linking error as below:
    --------------------Configuration: InvokeJava - Win32 Debug--------------------
    Compiling...
    invoke.c
    invoke.obj : error LNK2001: unresolved external symbol __imp__JNI_CreateJavaVM@12
    invoke.exe : fatal error LNK1120: 1 unresolved externals
    Error executing cl.exe.
    InvokeJava.exe - 2 error(s), 0 warning(s)
    Please help me.
    Code is pasted below:
    #include<stdlib.h>
    #include <jni.h>
    #define PATH_SEPARATOR ';' /* define it to be ':' on Solaris */
    #define USER_CLASSPATH "." /* where Prog.class is */
    main() {
         JNIEnv *env;
         JavaVM *jvm;
         jint res;
         jclass cls;
         jmethodID mid;
         jstring jstr;
         jclass stringClass;
         jobjectArray args;
    #ifdef JNI_VERSION_1_2
         JavaVMInitArgs vm_args;
         JavaVMOption options[1];
         options[0].optionString =
              "-Djava.class.path=" USER_CLASSPATH;
         vm_args.version = 0x00010002;
         vm_args.options = options;
         vm_args.nOptions = 1;
         vm_args.ignoreUnrecognized = JNI_TRUE;
         /* Create the Java VM */
         res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    #else
         JDK1_1InitArgs vm_args;
         char classpath[1024];
         vm_args.version = 0x00010001;
         JNI_GetDefaultJavaVMInitArgs(&vm_args);
         /* Append USER_CLASSPATH to the default system class path */
         sprintf(classpath, "%s%c%s",
              vm_args.classpath, PATH_SEPARATOR, USER_CLASSPATH);
         vm_args.classpath = classpath;
         /* Create the Java VM */
         res = JNI_CreateJavaVM(&jvm, &env, &vm_args);
    #endif /* JNI_VERSION_1_2 */
         if (res < 0) {
              fprintf(stderr, "Can't create Java VM\n");
              exit(1);
         cls = (*env)->FindClass(env, "Prog");
         if (cls == NULL) {
              goto destroy;
         mid = (*env)->GetStaticMethodID(env, cls, "main",
              "([Ljava/lang/String;)V");
         if (mid == NULL) {
              goto destroy;
         jstr = (*env)->NewStringUTF(env, " from C!");
         if (jstr == NULL) {
              goto destroy;
         stringClass = (*env)->FindClass(env, "java/lang/String");
         args = (*env)->NewObjectArray(env, 1, stringClass, jstr);
         if (args == NULL) {
              goto destroy;
         (*env)->CallStaticVoidMethod(env, cls, mid, args);
    destroy:
         if ((*env)->ExceptionOccurred(env)) {
              (*env)->ExceptionDescribe(env);
         (*jvm)->DestroyJavaVM(jvm);
    }

    Hi,
    you have to link jni.lib with your code. This lib is contained in the lib subdirectory of your JDK. Add jni.lib to the list of libraries and don't forget to add the directory where jni.lib is located to the library search path.
    Martin

Maybe you are looking for