0

I'm not used to making makefiles. My old project had all the makefiles in place and I'm making this from scratch for a small test with a lot of canned lib dependencies that I'm not used to either. It's been a few years since I looked at makefiles.

I have a directory called libopcTest with the following in it:

LibOPCTest.cc
LibOPCTest.h
makefile

makefile has this in it:

INC=-I/usr/include/libxml2/libxml
LIB=-L/usr/include/libxml2/libxml
all: LibOPCTest.exe

LibOPCTest.exe: LibOPCTest.o
>tab> gcc -o LibOPCTest.exe LibOPCTest.o

LibOPCTest.o: LibOPCTest.cpp
>tab> gcc -c $(INC) $(LIB) LibOPCTest.cpp

clean:
>tab> rm LibOPCTest.o LibOPCTest.exe

I looked in /usr/include/libxml2/libxml and it does have xmlstring.h in it. I don't see the libxml reference in opc.h, but apparently that's where it comes in, presumably in an include file, like config.h.

Plus, we have LibOPCTest.cpp which #includes <opc/opc.h> and it's own .h file.

main is in LibOPCTest.cpp.

When I type make at the Linux command prompt, I get the following error:

In file included from /usr/include/opc/opc.h:36:0, from LibOPCTest.cpp:1:
/usr/include/opc/config.h:37:30: fatal error: libxml/xmlstring.h: no such file or directory.

Shouldn't I have the libxml with the LIB and INC definition in the makefile pointing to libxml? I don't think I'm supposed to add anything to opc.h, including build it, since it's a canned library.

I was looking at this makefile example, and I think I have everything I need (probably not since it's not building).

I know it's a basic question, but hopefully someone has a good suggestion. Thanks for being nice in advance!!

Community
  • 1
  • 1
Michele
  • 3,617
  • 12
  • 47
  • 81
  • 3
    If you tell GCC to look for the headers in `/usr/include/libxml2/libxml`, then it will. And there's no `libxml/xmlstring.h` file in there. You probably wanted to write `-I/usr/include/libxml2` instead. (The compiler is ***always*** right, and you need to think about what things mean before hammering random code into the Makefile.) Also, your `-L` flag is nonsense; why would the linker care about the header files? That should most probably be `-L/usr/lib` or maybe a subdirectory thereof. – The Paramagnetic Croissant Oct 14 '14 at 18:56
  • 2
    Actually, just use `pkg-config --cflags libxml-2.0` and `pkg-config --libs libxml-2.0` – o11c Oct 14 '14 at 19:59
  • @011c - does that go in the makefile? Where? I fixed what TheParamagneticCroissant suggested, and it's having a huge amount of undefined references to silly things like operator delete, as well as xmlStrcmp, xmlTextREaderConstValue, etc..... Something is clearly amiss. – Michele Oct 14 '14 at 20:03
  • 1
    Well after Paramagnet's answer your compile time error might have vanished. What you are getting now is the link time error. just give proper arguments for LIB variable which would point to your libxml and default library path are set accordinly – Sagar Sakre Oct 15 '14 at 04:46
  • @TheParamagneticCroissant I think your claim that "the compiler is **always** right" is probably a wee bit over-stated. Compiler bugs do happen on occasion. However, it's generally a good idea to at least initially assume that the compiler knows what it's talking about... – twalberg Oct 16 '14 at 16:38
  • @twalberg well, technically, you're right. It's typically not users who don't even know about header files that discover such compiler bugs. – The Paramagnetic Croissant Oct 16 '14 at 16:48

1 Answers1

0

We decided to put the Linux version of libOPC on hold because there isn't a good 64 bit version and it needs a lot of work.

Michele
  • 3,617
  • 12
  • 47
  • 81