Hi, Francisco Carlos,

Thanks for your reply. I do add ifndef in mycode. I have added a lot
self-defined fucns before by adding the ifndef-define-endif. BUt this
morning, I always suffer from this error. The errors are as follows:

build/X86/mem/cache/lib.o.partial: In function `****':
/home/syuan3/gem5/build/X86/mem/heap.hh:17: multiple definition of `****'
build/X86/cpu/o3/lib.o.partial:/home/syuan3/gem5/build/X86/mem/heap.hh:17:
first defined here
collect2: error: ld returned 1 exit status
scons: *** [build/X86/gem5.opt] Error 1
scons: building terminated because of errors

Best regards.

Yuan

On Thu, Nov 7, 2019 at 9:52 AM Francisco Carlos <juninho.u...@hotmail.com>
wrote:

> Hi, Yuan
>
> Did you use #ifdef in your file my_func.hh?
>
> You should use #ifdef to avoid multiple definitions and circular includes.
>
> So, in the first line of your file my_func.hh, you must insert the
> following code:
>
> #ifndef _MEM_MY_FUNC_HH_
> #define  _MEM_MY_FUNC_HH_
>
> And in the last line of your file my_func.hh, you insert the code:
>
> #endif
>
>
> I think this should solve your problem.
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------------
> Francisco Carlos Silva Junior
> PhD Student at University of Brasilia
>
>
> ------------------------------
> *De:* gem5-users <gem5-users-boun...@gem5.org> em nome de yuan <
> syu...@ncsu.edu>
> *Enviado:* quinta-feira, 7 de novembro de 2019 11:28
> *Para:* gem5 users mailing list <gem5-users@gem5.org>
> *Assunto:* [gem5-users] Question about compile after adding global funcs
>
>
> Hi, All,
>
>
>
> I suffered one problem of multiple definition when compiling, what I did
> is adding some new functions I need in a file name my_func.hh under
> src/mem/, and in the file cache.cc where I need these functions I use
> #include “mem/my_func.hh”, but when I re-compile the gem5, it always shows
> the error of multiple definition of “the name of my func”. Does anyone have
> some hints on this?
>
>
>
> Best,
>
>
>
> Yuan
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
> _______________________________________________
> gem5-users mailing list
> gem5-users@gem5.org
> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
_______________________________________________
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to