Jump to content

[cygwin64] link error when including tlm


Fabien Dupont

Recommended Posts

Hi everyone,

I know cygwin is a bit of an "exotic" configuration for playing with systemc, but Visual Studio is out of reach for me, so I hope you will help me. I have had such a config working a few months ago, but must rebuild one due to a machine change. I knw it can work ! :)

I have compiled systemc PoC from source under cygwin64 using g++11.2 (and also 7.4 as part of my debug trials). "make check" goes fine, every tests are passed

When building a simple "hello world" program, everything goes well, as long as <tlm> header is not involved.

When <tlm> is included, I get the following error :

/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccS0Rolf.o:trial.cpp:(.text+0x2e3): undefined reference to `tlm::tlm_extension_base::register_extension(std::type_info const&)'
collect2: error: ld returned 1 exit status

Sample code :

#include <tlm> // comment this to have build ok
#include <systemc>

int sc_main(int argc, char *argv[])
{
    return 0;
}

Configure :

 ../configure --enable-pthreads --with-arch_suffix=

build command:

g++ -I/cygdrive/d/c_cpp/systemc-2.3.3/include -L/cygdrive/d/c_cpp/systemc-2.3.3/lib -lsystemc trial.cpp

I have tried different c++ (both for building systemc lib and my application) to no avail. I have tried retro-grading to systemc 2.3.2, same results. 

FYI, the undefined reference is used for initialization of const static member of a templated class, file tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h line 73 to 85:

template <typename T>
class tlm_extension : public tlm_extension_base
{
public:
    virtual tlm_extension_base* clone() const = 0;
    virtual void copy_from(tlm_extension_base const &ext) = 0;
    virtual ~tlm_extension() {}
    const static unsigned int ID;
};

template <typename T>
const unsigned int tlm_extension<T>::ID
  = tlm_extension_base::register_extension(typeid(T));

The function is correctly implemented in tlm_gp.cpp.

 

Has anyone already faced the issue ? I guess I missed something since I had it working a few months ago.

Thanks in advance for your help !
 

Link to comment
Share on other sites

Is there any universal law that says that you have to find the answer to your problem AFTER you asked some help ? Especially when the answer is as simple as :

replace

g++ -I/cygdrive/d/c_cpp/systemc-2.3.3/include -L/cygdrive/d/c_cpp/systemc-2.3.3/lib -lsystemc trial.cpp

by :

 

g++ trial.cpp -I/cygdrive/d/c_cpp/systemc-2.3.3/include -L/cygdrive/d/c_cpp/systemc-2.3.3/lib -lsystemc

 

You can laugh at me now.

 

Can someone explain me, though ?

 

Thanks and sorry.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...