最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Ubuntu下Eclipse中交叉编译C项目出错:Symbol ‘NULL’ could not be resolved

Eclipse crifan 7765浏览 0评论

【问题】

折腾:

【记录】Ubuntu下使用Eclipse编译项目

期间,虽然之前已经解决了:

【已解决】Eclipse通过Makefile调用交叉编译器交叉编译C项目出错:Type ‘FILE’ could not be resolved

以及:

【已解决】Eclipse中交叉编译C项目出错:Symbol ‘SETVAL’ could not be resolved

但是,还是无法消除错误:

Description    Resource    Path    Location    Type
Symbol ‘NULL’ could not be resolved    wbmport.c    /HART-IP/WBM/Src    line 555    Semantic Error

eclipse 87 symbol null could not be resolved

【解决过程】

1.此处,参考:

Eclipse CDT “Symbol NULL could not be resolved”

确定是已经包含了对应的头文件的:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

但是就是找不到NULL。

2.去看了下,stdio.h中,也是去包含了对应的stddef.h的。

stdio contain stddef

3.然后再去看了看,发现:

stdio.h和stdlib.h,都包含了:

#define __need_NULL
#include <stddef.h>

但是,此处,却找不到对应的stddef.h。

所以,去搜一下,看看交叉编译器中是否有stddef.h:

发现是有的,而且有两处,然后看了sysroot/usr/linux中的:

crifan@ubuntu:xscale$ find . -name stddef.h
./gcc-4.6.0-glibc-2.9/lib/gcc/arm-xscale-linux-gnueabi/4.6.0/include/stddef.h
./gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux/stddef.h
crifan@ubuntu:xscale$ ls ./gcc-4.6.0-glibc-2.9/lib/gcc/arm-xscale-linux-gnueabi/4.6.0/include
arm_neon.h  float.h  iso646.h  mmintrin.h  stdarg.h  stdbool.h  stddef.h  stdfix.h  stdint-gcc.h  stdint.h  unwind.h  varargs.h
crifan@ubuntu:xscale$ ls ./gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux
acct.h             coda_psdev.h            gfs2_ondisk.h    inotify.h         nbd.h               ppdev.h            sunrpc
adb.h              coff.h                  gigaset_dev.h    input.h           ncp_fs.h            ppp-comp.h         synclink.h
adfs_fs.h          comstats.h              hayesesp.h       in_route.h        ncp.h               ppp_defs.h         sysctl.h
affs_hardblocks.h  connector.h             hdlc             ioctl.h           ncp_mount.h         prctl.h            tc_act
agpgart.h          consolemap.h            hdlcdrv.h        ipc.h             ncp_no.h            ps2esdi.h          tcp.h
aio_abi.h          cramfs_fs.h             hdlc.h           ip.h              neighbour.h         ptrace.h           telephony.h
a.out.h            cuda.h                  hdreg.h          ipmi.h            netdevice.h         qic117.h           termios.h
apm_bios.h         cyclades.h              hdsmart.h        ipmi_msgdefs.h    netfilter           qnx4_fs.h          ticable.h
arcfb.h            cycx_cfm.h              hiddev.h         ip_mp_alg.h       netfilter_arp       qnxtypes.h         time.h
atalk.h            dccp.h                  hpet.h           ipsec.h           netfilter_arp.h     quota.h            times.h
atmapi.h           dirent.h                hysdn_if.h       ipv6.h            netfilter_bridge    quotaio_v1.h       timex.h
atmarp.h           divert.h                i2c-dev.h        ipv6_route.h      netfilter_bridge.h  quotaio_v2.h       tiocl.h
atmbr2684.h        dlm_device.h            i2c.h            ipx.h             netfilter_decnet.h  radeonfb.h         tipc.h
atmclip.h          dlm.h                   i2o-dev.h        irda.h            netfilter.h         raid               toshiba.h
atmdev.h           dm-ioctl.h              i8k.h            isdn              netfilter_ipv4      random.h           tty.h
atm_eni.h          dn.h                    icmp.h           isdn_divertif.h   netfilter_ipv4.h    raw.h              types.h
atm.h              dqblk_v1.h              icmpv6.h         isdn.h            netfilter_ipv6      reboot.h           udf_fs_i.h
atm_he.h           dqblk_v2.h              if_addr.h        isdnif.h          netfilter_ipv6.h    reiserfs_fs.h      udp.h
atm_idt77105.h     dqblk_xfs.h             if_arcnet.h      isdn_ppp.h        net.h               reiserfs_xattr.h   uinput.h
atmioc.h           dvb                     if_arp.h         isicom.h          netlink.h           resource.h         uio.h
atmlec.h           efs_fs_sb.h             if_bonding.h     iso_fs.h          netrom.h            romfs_fs.h         ultrasound.h
atmmpc.h           elfcore.h               if_bridge.h      ixjuser.h         nfs2.h              rose.h             un.h
atm_nicstar.h      elf-em.h                if_cablemodem.h  jbd.h             nfs3.h              route.h            unistd.h
atmppp.h           elf-fdpic.h             if_ec.h          jffs2.h           nfs4.h              rtc.h              usb_ch9.h
atmsap.h           elf.h                   if_eql.h         joystick.h        nfs4_mount.h        rtnetlink.h        usbdevice_fs.h
atmsvc.h           errno.h                 if_ether.h       kdev_t.h          nfsacl.h            scc.h              user.h
atm_tcp.h          errqueue.h              if_fc.h          kd.h              nfsd                sched.h            utime.h
atm_zatm.h         ethtool.h               if_fddi.h        kernelcapi.h      nfs_fs.h            sctp.h             utsname.h
audit.h            eventpoll.h             if_frad.h        kernel.h          nfs.h               sdla.h             version.h
auto_fs4.h         ext2_fs.h               if.h             keyboard.h        nfs_idmap.h         selinux_netlink.h  video_decoder.h
auto_fs.h          ext3_fs.h               if_hippi.h       keyctl.h          nfs_mount.h         sem.h              videodev2.h
auxvec.h           fadvise.h               if_infiniband.h  limits.h          n_r3964.h           serial_core.h      videodev.h
awe_voice.h        fb.h                    if_link.h        llc.h             nubus.h             serial.h           video_encoder.h
ax25.h             fcntl.h                 if_ltalk.h       lock_dlm_plock.h  nvram.h             serio.h            videotext.h
b1lli.h            fd.h                    if_packet.h      loop.h            oom.h               shm.h              vt.h
baycom.h           fdreg.h                 if_plip.h        lp.h              param.h             signal.h           wait.h
bfs_fs.h           fib_rules.h             if_ppp.h         magic.h           parport.h           smb_fs.h           wanrouter.h
binfmts.h          filter.h                if_pppox.h       major.h           patchkey.h          smb.h              watchdog.h
blkpg.h            flat.h                  if_shaper.h      matroxfb.h        pci.h               smb_mount.h        wireless.h
bpqether.h         fs.h                    if_slip.h        mempolicy.h       pci_ids.h           smbno.h            x25.h
byteorder          ftape.h                 if_strip.h       meye.h            pci_regs.h          snmp.h             xattr.h
capability.h       ftape-header-segment.h  if_tr.h          mii.h             personality.h       socket.h           xfrm.h
capi.h             ftape-vendors.h         if_tun.h         minix_fs.h        pfkeyv2.h           sockios.h          zftape.h
cciss_ioctl.h      fuse.h                  if_tunnel.h      mman.h            pg.h                som.h              zorro_ids.h
cdk.h              futex.h                 if_vlan.h        mmtimer.h         pktcdvd.h           sonet.h
cdrom.h            gameport.h              if_wanpipe.h     mqueue.h          pkt_cls.h           sonypi.h
chio.h             generic_serial.h        igmp.h           mroute.h          pkt_sched.h         soundcard.h
cm4000_cs.h        genetlink.h             in6.h            msdos_fs.h        pmu.h               sound.h
cn_proc.h          genhd.h                 inet_diag.h      msg.h             poll.h              stat.h
coda.h             gen_stats.h             in.h             mtio.h            posix_types.h       stddef.h
crifan@ubuntu:xscale$ cd ./gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux
crifan@ubuntu:linux$ pwd
/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux
crifan@ubuntu:linux$ 

所以,就是去把上面的路径:

/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux

加上之前的项目的GNU C和GNU C++的include中即可:

gnu c add include linux

gnu c   added include linux

然后再去重新refresh试试,结果还是一堆的NULL无法解析。

4.后来,无意间发现:

把当前打开的文件,其包含了NULL的那些文件,都关闭掉,然后重新刷新一下,重新clean再重新build一下,就可以解除此错误了:

no null error just some other error

 

【总结】

此处,Eclipse中交叉编译C项目,出错:

Symbol ‘NULL’ could not be resolved

的原因是:

因为没有把NULL的定义所在的文件stddef.h所在的路径

xxx/include/linux

加入到当前项目的include

所以解决办法是:

把对应的include/linux路径

加到对应的项目的include中即可:

右击项目->C/C++ General->Paths and Symbols->Include,对于GNU C和GNU C++,都去Add添加上对应的此include/linux路径

此处,交叉编译器中,包含了stddef.h的路径是:

/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux

注:

如果不会查找,可参考:

【记录】Ubuntu中尝试在/opt/crosscompile/xscale中找stdio.h

转载请注明:在路上 » 【已解决】Ubuntu下Eclipse中交叉编译C项目出错:Symbol ‘NULL’ could not be resolved

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.169 seconds, using 22.26MB memory