Disabling OpenMP in compiler options produce tons of reference errors - c

I have a project in C and I need to measure program performance in parallel and sequential mode.
Program is parallelized with openmp.
If I compile my program with -openmp flag everything is fine.
But if I replace -openmp with -openmp-stubs I get tons of reference errors:
ccc.c:614: undefined reference to `__kmpc_for_static_init_4'
ccc.c:614: undefined reference to `__kmpc_for_static_fini'
ccc.c:624: undefined reference to `__kmpc_barrier'
build/liblcthw.a(ccc.o): In function `deusv2v_dbg':
ccc.c:632: undefined reference to `__kmpc_global_thread_num'
ccc.c:632: undefined reference to `__kmpc_ok_to_fork'
ccc.c:632: undefined reference to `__kmpc_fork_call'
ccc.c:632: undefined reference to `__kmpc_serialized_parallel'
ccc.c:632: undefined reference to `__kmpc_end_serialized_parallel'
build/liblcthw.a(ccc.o): In function `L_deusv2v_dbg_632__par_region0_2_862':
ccc.c:636: undefined reference to `__kmpc_for_static_init_4'
ccc.c:636: undefined reference to `__kmpc_for_static_fini'
ccc.c:646: undefined reference to `__kmpc_barrier'
build/liblcthw.a(ccc.o): In function `seusv2v_dbg':
ccc.c:654: undefined reference to `__kmpc_global_thread_num'
ccc.c:654: undefined reference to `__kmpc_ok_to_fork'
ccc.c:654: undefined reference to `__kmpc_fork_call'
ccc.c:654: undefined reference to `__kmpc_serialized_parallel'
ccc.c:654: undefined reference to `__kmpc_end_serialized_parallel'
build/liblcthw.a(ccc.o): In function `L_seusv2v_dbg_654__par_region0_2_954':
ccc.c:658: undefined reference to `__kmpc_for_static_init_4'
ccc.c:658: undefined reference to `__kmpc_for_static_fini'
ccc.c:668: undefined reference to `__kmpc_barrier'
Compiler: icc version 13.1.3 (gcc version 4.4.6 compatibility)
What I'm doing wrong? Is it possible to temporary disable openmp in other way?
I use omp_get_wtime to measure performance time so I can't just disable OpenMP at all.

Related

why is the error of Undefined symbol detected in semantic analysis?

According to me ,An undefined symbol should be detected in parsing phase since after token is made in the lexical phase , then its type is undefined and if we try to assign a value to that undefined symbol , then how is the parse tree constructed without any error ?
int a;
b=19;
Here , the for symbol b , token has already been generated by the lexical analyser and value is as well associated with it , so what is done in the parsing phase due to which the undefined symbol is not detected in this phase ?

Enabling UBIFS in U-BOOT

I am attempting to enable UBIFS support into u-boot but have encountered several undefined reference errors when compiling. In my board configuration, I have enabled the following:
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
#define CONFIG_CMD_MTDPARTS
#define CONFIG_CMD_UBI
#define CONFIG_RBTREE
#define CONFIG_CMD_UBIFS
#define CONFIG_LZO
And get the following undefined reference errors when compiling:
uboot/fs/ubifs/lpt_commit.c:1232: undefined reference to dbg_chk_lpt_free_spc
uboot/fs/ubifs/lpt_commit.c:1235: undefined reference to `dbg_check_ltab'
fs/built-in.o: In function `layout_cnodes':
uboot/fs/ubifs/lpt_commit.c:322: undefined reference to `ubifs_dump_lpt_lebs'
fs/built-in.o: In function `ubifs_add_bud_to_log':
uboot/fs/ubifs/log.c:194: undefined reference to `ubifs_commit_required'
uboot/fs/ubifs/log.c:225: undefined reference to `ubifs_request_bg_commit'
uboot/fs/ubifs/log.c:265: undefined reference to `ubifs_write_node'
fs/built-in.o: In function `ubifs_log_end_commit':
uboot/fs/ubifs/log.c:479: undefined reference to `ubifs_write_master'
fs/built-in.o: In function `do_write_orph_node':
uboot/fs/ubifs/orphan.c:248: undefined reference to `ubifs_write_node'
dbg_chk_lpt_free_spc, db_check-ltab, ubifs_dump_lpt_lebs, ubifs_write_node, and ubifs_write_master are"ifdef'd" out (#ifndef __UBOOT__ but...obviously __UBOOT__ is defined).
With a quick grep, ubifs_commit_required, ubifs_request_bg_commit are completely missing implementations.
Does u-boot not support UBIFS entirely, or is it currently broken? (Using 2016.07 release). Or am I perhaps missing a step...
UBIFS was indeed broken in the mainline for several architectures. A proposed patch can be found in the pipemail at http://lists.denx.de/pipermail/u-boot/2016-September/265474.html, but it hasn't been approved yet. The patch applied without issues and I can now compile, though whether the filesystem works with it remains to be seen...

Linking errors when compiling using Microchip C30 compiler for Openpicus

I am compiling a project with lot of external libraries. The project has some warnings , but i believe that it should not hamper the creation of the .hex file. So when i compile the project I get a list of linking errors.
Compiling C:\liblwm2m\Libs\ExternalLib\heap.s
* Total program memory used (bytes): 0x28ef3 (167667) 64%
* Total data memory used (bytes): 0x360a (13834) 84%
x_object_device.o(.text+0x688):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x68a):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6b6):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6b8):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6e4):C:\liblwm2m\Libs\ExternalLib\object_device.c: undefined reference to `strdup'
x_object_device.o(.text+0x6e6):C:\liblwm2m\Libs\ExternalLib\object_device.c: more undefined references to `strdup' follow
x_observe.o(.text+0x3c2):C:\liblwm2m\Libs\ExternalLib\observe.c: undefined reference to `object_read'
x_observe.o(.text+0x3c4):C:\liblwm2m\Libs\ExternalLib\observe.c: undefined reference to `object_read'
x_liblwm2m.o(.text+0x86):C:\liblwm2m\Libs\ExternalLib\liblwm2m.c: undefined reference to `strdup'
x_liblwm2m.o(.text+0x88):C:\liblwm2m\Libs\ExternalLib\liblwm2m.c: undefined reference to `strdup'
x_management.o(.text+0x48):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_read'
x_management.o(.text+0x4a):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_read'
x_management.o(.text+0xa6):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0xa8):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0x154):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_isInstanceNew'
x_management.o(.text+0x156):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_isInstanceNew'
x_management.o(.text+0x16e):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0x170):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_create'
x_management.o(.text+0x188):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x18a):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x1a2):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_execute'
x_management.o(.text+0x1a4):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_execute'
x_management.o(.text+0x1da):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x1dc):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_write'
x_management.o(.text+0x208):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_delete'
x_management.o(.text+0x20a):C:\liblwm2m\Libs\ExternalLib\management.c: undefined reference to `object_delete'
x_registration.o(.text+0x8c):C:\liblwm2m\Libs\ExternalLib\registration.c: undefined reference to `prv_getRegisterPayload'
x_registration.o(.text+0x8e):C:\liblwm2m\Libs\ExternalLib\registration.c: undefined reference to `prv_getRegisterPayload'
C:\Program Files\Microchip\MPLAB C30\bin\bin/pic30-coff-bin2hex.exe: a.cof could not be opened.
The system cannot find the file specified.
---------------------------------- COMPILING ERROR ---------------------------------------
Here the strdup function is in which is supported by openpicus and i have also declared it. What surprises me is that the program compiles correctly but throws linking errors. Any thoughts about this ?
Thanks in advance
These are the errors in the code
undefined reference to strdup'
undefined reference toobject_read'
undefined reference to object_create'
undefined reference toobject_isInstanceNew'
undefined reference to object_create'
undefined reference toobject_write'
undefined reference to object_execute'
undefined reference toobject_write'
undefined reference to object_delete'
undefined reference toprv_getRegisterPayload'
P.S. these are not warnings!!
The error indicates that there is no definition of the functions "strdup", ... , "prv_getRegisterPayload". The linker does not find the references to these routines, and it terminates with a link time error. No linking means no hex file produced, that is the standard behavior of all toolchains.
Check the libraries that you have attached to the project. Add the libraries that have references/definitions for these routines, and the code should then build fine.
A pseudo code that will produce a similar error is as:
extern void parabola ();
int main(void)
{
parabola (); // ERROR here "undefined reference to `parabola'
}
-- Where is the definition of the function parabola? Shouldn't it be
void parabola ()
{}
int main(void)
{
parabola (); // Builds like magic
}

Does this C code produce "undefined behavior"?

I'm reading an interesting article A Guide to Undefined Behavior in C and C++, Part 1 on undefined behavior in C and C++. Often I do the following in my code:
int i = 10;
i = (++i) % 7;
Does this produce undefined behavior? On x86? ARM? Perhaps it depends on the compiler?
It's undefined behavior because i is modified more than once without an intervening sequence point.
It depends on the compiler only in the sense that there are no requirements about what the code will do, so every compiler can do something different. To be clear - just because even though you get results that seem to make sense (sometimes), the code is a bug.
Yes - as per standard ISO C.
Is this undefined C behaviour?
What are all the common undefined behaviours that a C++ programmer should know about?
Though, a compiler is expected to produce consistent result.

What does this `ld` error ("undefined reference") mean?

What does this error mean?
/tmp/ccevEqoI.o: In function `main':
funcptr.c:(.text+0x61): undefined reference to `AddALL'
collect2: ld returned 1 exit status
I'm trying to write a function which adds all the integers up to the limit
entered by the user.
Transcribed 'answer' which is a comment from the OP:
I wrote a program that would add all the integers upto the limit Specified. For that I had to write a function. So I made a function called 'AddAll' but when I called it from my program I called it as 'AddALL'.
Note: C is case sensitive. Eventually when I changed the name of the function where I was calling it. It compiled perfectly :)
Just thought that this piece of info would be useful to beginners.
It means that the linker (that is called ld in gcc) did not found the symbol AddALL in the specified object files. Basically, there is no body for that function or it's a variable declared as extern with no definition.
It tells you that the definition for the function 'AddALL' could not be found. Make sure that you include the object file that contains 'AddALL' when you compile/link.

Resources