netmail-open / wjelement

advanced, flexible JSON manipulation in C
GNU Lesser General Public License v3.0
108 stars 56 forks source link

WJESchemaValidate not linking in Unix build ? #90

Closed Fulguritude closed 3 years ago

Fulguritude commented 4 years ago

I'm getting an "undefined symbol" error for WJESchemaValidate when linking the wjelement library (built from source on Mac OS X). The rest of the library (that I've used) works fine (thanks, btw!).

Here is the result of nm on the build, you can see that WJESchemaValidate is indeed absent:

lib/wjelement/libwjelement_unix.a(xpl.o):
0000000000000d90 T _MemMallocEx
                 U ___memset_chk
                 U ___stack_chk_fail
                 U ___stack_chk_guard
                 U ___vsnprintf_chk
0000000000000c50 T __skipspace
0000000000000000 T _asprintf
0000000000000bc0 T _chopspace
                 U _free
                 U _isspace
                 U _malloc
                 U _memchr
                 U _realloc
                 U _strchr
00000000000005d0 T _strichr
0000000000000b50 T _stripat
0000000000000790 t _stripat_r
0000000000000740 T _stripatn
0000000000000670 T _stristrn
                 U _strlen
                 U _strncasecmp
00000000000003f0 T _strprintf
0000000000000d00 T _strspace
                 U _toupper
00000000000002b0 T _vstrcatf

lib/wjelement/libwjelement_unix.a(element.o):
                 U _MemMallocEx
0000000000000630 T _WJEAttach
0000000000000000 T _WJEChanged
0000000000001d00 T _WJEDump
0000000000001dd0 T _WJEDumpFile
00000000000015a0 T _WJEFromFile
0000000000000f30 t _WJEMemCallback
0000000000002030 T _WJEMemFree
0000000000002060 T _WJEMemRelease
0000000000001b90 T _WJEMergeObjects
0000000000001f40 T _WJEReadFILE
00000000000007a0 T _WJERename
0000000000001680 T _WJEToFile
0000000000001d30 T _WJEWriteFILE
                 U _WJRCloseDocument
                 U _WJRFileCallback
                 U _WJRIntOrDouble
                 U _WJRNegative
                 U _WJRNext
                 U _WJRStringEx
                 U _WJWBoolean
                 U _WJWCloseArray
                 U _WJWCloseDocument
                 U _WJWCloseObject
                 U _WJWDouble
                 U _WJWFileCallback
                 U _WJWInt64
                 U _WJWNull
                 U _WJWOpenArray
                 U _WJWOpenMemDocument
                 U _WJWOpenObject
                 U _WJWStringN
                 U _WJWUInt64
                 U __WJEChild
0000000000000420 T __WJECloseDocument
0000000000001820 t __WJECopy
0000000000001760 T __WJECopyDocument
00000000000002f0 T __WJEDetach
0000000000000950 t __WJELoad
0000000000000040 T __WJENew
00000000000008e0 T __WJEOpenDocument
0000000000000200 T __WJEReset
00000000000010c0 T __WJEToString
0000000000001150 T __WJEWriteDocument
                 U __WJROpenDocument
                 U __WJWOpenDocument
                 U ___WJEBool
0000000000000e80 T ___WJEFromString
                 U ___WJEString
                 U ___error
                 U ___memcpy_chk
                 U ___memset_chk
                 U ___stack_chk_fail
                 U ___stack_chk_guard
                 U ___stdoutp
                 U ___strncpy_chk
                 U _fclose
                 U _fflush
0000000000001fd0 t _fileReaderCB
                 U _fopen
                 U _fprintf
                 U _fread
                 U _free
                 U _malloc
                 U _memchr
                 U _printf
                 U _strcasecmp
                 U _strdup
                 U _strlen
                 U _strprintf
                 U _time

lib/wjelement/libwjelement_unix.a(hash.o):
0000000000000000 T _WJEHash
0000000000000030 t __WJEHash
                 U ___WJEBool
                 U ___WJEInt32
                 U ___WJEString
                 U _strlen

lib/wjelement/libwjelement_unix.a(search.o):
0000000000000f80 t _WJECheckCondition
0000000000001520 t _WJECleanName
00000000000005e0 t _WJEDepth
0000000000001dc0 t _WJEMatchAll
0000000000002610 t _WJEMatchExact
0000000000001b20 t _WJEMatchNone
0000000000001e00 t _WJEMatchSubscript
0000000000000650 t _WJENext
0000000000000730 t _WJENextName
0000000000001b50 t _WJENextNameCheck
0000000000000000 T _WJESearch
0000000000001ad0 T __WJEAny
00000000000018f0 T __WJEChild
00000000000018a0 T __WJEGet
00000000000026d0 t __WJEIndex
                 U __WJENew
                 U __WJEReset
                 U ___WJEDouble
                 U ___WJEString
                 U ___memmove_chk
                 U ___stderrp
                 U __skipspace
                 U _fprintf
                 U _free
                 U _isalnum
                 U _isalpha
                 U _isspace
                 U _strcasecmp
                 U _strcmp
                 U _stripatn
                 U _strlen
                 U _strncasecmp
                 U _strncmp
                 U _strndup
                 U _strtod
                 U _strtol

lib/wjelement/libwjelement_unix.a(types.o):
0000000000002740 T _WJEArrayF
0000000000001de0 T _WJEBoolF
                 U _WJEChanged
0000000000003540 T _WJEDoubleF
0000000000001a50 T _WJEGetF
0000000000002c00 T _WJEInt32F
00000000000030a0 T _WJEInt64F
00000000000029a0 T _WJENullF
00000000000024e0 T _WJEObjectF
0000000000001ca0 t _WJEPathF
                 U _WJESearch
0000000000002030 T _WJEStringF
0000000000002280 T _WJEStringNF
0000000000002e50 T _WJEUInt32F
00000000000032f0 T _WJEUInt64F
                 U __WJEGet
00000000000037b0 t __WJEGetNum
0000000000000e60 t __WJENum
                 U __WJEReset
00000000000038b0 t __WJESetNum
0000000000000a70 T ___WJEArray
0000000000000000 T ___WJEBool
00000000000014b0 T ___WJEDouble
0000000000000df0 T ___WJEInt32
00000000000013b0 T ___WJEInt64
0000000000000c30 T ___WJENull
00000000000008b0 T ___WJEObject
0000000000000420 T ___WJEString
00000000000004c0 T ___WJEStringN
0000000000001330 T ___WJEUInt32
0000000000001430 T ___WJEUInt64
                 U ___stack_chk_fail
                 U ___stack_chk_guard
                 U ___strncpy_chk
                 U __skipspace
                 U _free
                 U _malloc
                 U _strcasecmp
                 U _strcmp
                 U _strlen
                 U _strtoull
                 U _vstrcatf

lib/wjelement/libwjelement_unix.a(wjreader.o):
                 U _MemMallocEx
0000000000001480 T _WJRBoolean
0000000000000530 T _WJRCloseDocument
0000000000001440 T _WJRDouble
0000000000001730 t _WJRDown
0000000000000630 T _WJRFileCallback
0000000000000200 t _WJRFillBuffer
0000000000002d20 T _WJRInt32
00000000000031f0 T _WJRInt64
0000000000003250 T _WJRIntOrDouble
0000000000000730 T _WJRMemCallback
0000000000002d00 T _WJRNegative
0000000000000840 T _WJRNext
0000000000002d50 t _WJRNumber
00000000000010f0 t _WJRSkipString
0000000000001b90 T _WJRStringEx
00000000000031c0 T _WJRUInt32
0000000000003220 T _WJRUInt64
0000000000002c10 t _WJRUp
0000000000000000 T __WJROpenDocument
                 U ___memcpy_chk
                 U ___memmove_chk
                 U ___memset_chk
                 U _fread
                 U _free
                 U _isalnum
                 U _isspace
                 U _memchr
                 U _memset
                 U _strlen
                 U _strtod
                 U _strtol
                 U _strtoll
                 U _strtoul
                 U _strtoull
                 U _toupper

lib/wjelement/libwjelement_unix.a(wjwriter.o):
                 U _MemMallocEx
0000000000001b30 T _WJWBoolean
0000000000000cf0 T _WJWCloseArray
0000000000000130 T _WJWCloseDocument
0000000000000fa0 T _WJWCloseObject
0000000000001a70 T _WJWDouble
0000000000000280 T _WJWFileCallback
00000000000012d0 T _WJWInt32
0000000000001770 T _WJWInt64
0000000000000330 t _WJWMemCallback
0000000000001ce0 T _WJWNull
0000000000001440 t _WJWNumber
0000000000000440 T _WJWOpenArray
00000000000002e0 T _WJWOpenMemDocument
0000000000000df0 T _WJWOpenObject
0000000000001e80 T _WJWRawValue
0000000000001240 T _WJWString
00000000000010a0 T _WJWStringN
00000000000015f0 T _WJWUInt32
00000000000018f0 T _WJWUInt64
0000000000002020 t _WJWUTF8CharSize
00000000000005f0 t _WJWrite
0000000000000930 t _WJWriteString
0000000000000000 T __WJWOpenDocument
                 U ___error
                 U ___memcpy_chk
                 U ___memmove_chk
                 U ___memset_chk
                 U ___sprintf_chk
                 U ___stack_chk_fail
                 U ___stack_chk_guard
                 U _free
                 U _fwrite
                 U _malloc
                 U _realloc
                 U _strlen
                 U _strprintf

Is there an easy fix that I am missing, or is this indeed a build error ?

Fulguritude commented 4 years ago

I answered my own question, the fix was simply to add appropriate schema.o lines to the Makefile. My code below:

CC=gcc
MAKEDIR=@mkdir -p $(@D)
BUILDDIR=unix/release
#CFLAGS=-c -Wall -DWJE_DISTINGUISH_INTEGER_TYPE -O3 -Iinclude
CFLAGS=-c -Wall -DWJE_DISTINGUISH_INTEGER_TYPE -g -DDEBUG -Iinclude

all: $(BUILDDIR)/libwjelement.a

$(BUILDDIR)/libwjelement.a: $(BUILDDIR)/xpl.o $(BUILDDIR)/element.o $(BUILDDIR)/schema.o $(BUILDDIR)/hash.o $(BUILDDIR)/search.o $(BUILDDIR)/types.o $(BUILDDIR)/wjreader.o $(BUILDDIR)/wjwriter.o
    $(MAKEDIR)
    ar rvs $@ $(BUILDDIR)/xpl.o $(BUILDDIR)/element.o $(BUILDDIR)/schema.o $(BUILDDIR)/hash.o $(BUILDDIR)/search.o $(BUILDDIR)/types.o $(BUILDDIR)/wjreader.o $(BUILDDIR)/wjwriter.o

$(BUILDDIR)/xpl.o: src/lib/xpl.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/element.o: src/wjelement/element.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/schema.o: src/wjelement/schema.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/hash.o: src/wjelement/hash.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/search.o: src/wjelement/search.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/types.o: src/wjelement/types.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/wjreader.o: src/wjreader/wjreader.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

$(BUILDDIR)/wjwriter.o: src/wjwriter/wjwriter.c
    $(MAKEDIR)
    $(CC) $(CFLAGS) $< -o $@

clean:
    rm $(BUILDDIR)/*

Should I do a pull request ? Or is schema.o voluntarily kept out of the build ?

Should I do a pull request where I make your Makefile more modular ? (it repeats itself a lot and would greatly improve by removing boilerplate)

penduin commented 4 years ago

Hey @Fulguritude , glad you found a solution! I would be happy to see a pull request. The repetition and boilerplate you're talking about, is that referring to the Makefiles that CMake generates, or our CMakeLists.txt files? (I ask because only the latter are part of the actual source tree. Either way I'm sure our makefiles are quite crufty and would welcome some attention :^)

Fulguritude commented 4 years ago

Hey @penduin

The file I copied and edited in particular is the Makefile-all at the top-level (which I had renamed Makefile to run with make; I had never used cmake in my life until today, which I did to try to understand what you were talking about xd).

Makefile-all doesn't seem to be a cmake-generated Makefile, but rather something that was used for old builds and then forgotten... Being a "raw Makefile" adept is probably why I landed on this issue.

If you'd like, I'll turn Makefile-all into a more "standard" Makefile, which respects your file structure (ie, not going through each CMakeLists.txt, but rather be a standalone that builds for your platform when you call make). If, on your end, you can compile a lib with just "make" from a raw repo clone, my job'll be successful, essentially.

penduin commented 4 years ago

Oh! Indeed I had forgotten all about Makefile-all -- you're exactly right. :^) Yes, I'd welcome an update to that; it predates wjeschema entirely! Being able to "make -f Makefile-all" will be great to have for anyone who doesn't wish to bother with CMake.

On 5/28/20, Fulguritude notifications@github.com wrote:

Hey @penduin

The file I copied and edited in particular is the Makefile-all at the top-level (which I had renamed Makefile to run with make; I had never used cmake in my life until today, which I did to try to understand what you were talking about xd).

Makefile-all doesn't seem to be a cmake-generated Makefile, but rather something that was used for old builds and then forgotten... Being a "raw Makefile" adept is probably why I landed on this issue.

If you'd like, I'll turn Makefile-all into a more "standard" Makefile, which respects your file structure (ie, not going through each CMakeLists.txt, but rather be a standalone that builds for your platform when you call make). If, on your end, you can compile a lib with just "make" from a raw repo clone, my job'll be successful, essentially.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/netmail-open/wjelement/issues/90#issuecomment-635581790