Skip to content

Unresolved symbols #5

@brmarkus

Description

@brmarkus

The documentation says

make # builds libfacex.a + facex-cli
make example # builds and runs example
make encrypt # builds weight encryption tool
Requirements: GCC with AVX2 support. Nothing else.

Cross-compile for Linux (from WSL)
gcc -O3 -march=x86-64-v3 -mavx2 -mfma -static
-DFACEX_LIB -o libfacex.a src/*.c -lm -lpthread

I'm using "Ubuntu 24.04.4 LTS" with "gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0" - natively, no Docker, no WSL.

I'm using a SoC "Intel(R) Core(TM) Ultra 9 185H".

And calling make from the project's root folder.

The following build command line gets printed as an example:

cc -O3 -march=native -mfma -funroll-loops -mavx512f -mavx512vnni -mprefer-vector-width=512 -DFACEX_LIB -c src/facex.c -o facex.o

After getting a couple of compiler warnings the build finally fails with linker errors:

/usr/bin/ld: /tmp/ccl7oGij.o: in function `v2_engine_init':
edgeface_engine_v2.c:(.text+0x36ce): undefined reference to `conv2d_hwc_reorder_weights'
/usr/bin/ld: edgeface_engine_v2.c:(.text+0x3719): undefined reference to `conv2d_hwc_reorder_weights'
/usr/bin/ld: edgeface_engine_v2.c:(.text+0x374c): undefined reference to `conv2d_hwc_reorder_weights'
/usr/bin/ld: edgeface_engine_v2.c:(.text+0x3d4e): undefined reference to `conv2d_hwc_reorder_weights'
/usr/bin/ld: edgeface_engine_v2.c:(.text+0x3d7b): undefined reference to `conv2d_hwc_reorder_weights'
/usr/bin/ld: /tmp/ccl7oGij.o:edgeface_engine_v2.c:(.text+0x3db5): more undefined references to `conv2d_hwc_reorder_weights' follow
/usr/bin/ld: /tmp/ccl7oGij.o: in function `v2_engine_forward':
edgeface_engine_v2.c:(.text+0x4d06): undefined reference to `convnext_block'
/usr/bin/ld: edgeface_engine_v2.c:(.text+0x595d): undefined reference to `conv2d_hwc'
/usr/bin/ld: edgeface_engine_v2.c:(.text+0x5a88): undefined reference to `xca_block'
collect2: error: ld returned 1 exit status
make: *** [Makefile:71: facex-v2] Error 1

I needed to remove/comment out static from those complained undefined reference method definitions:

diff --git a/download_weights.sh b/download_weights.sh
old mode 100644
new mode 100755
diff --git a/src/edgeface_engine.c b/src/edgeface_engine.c
index 1b19781..14abaee 100644
--- a/src/edgeface_engine.c
+++ b/src/edgeface_engine.c
@@ -221,7 +221,7 @@ static void xca_dw_conv_nchw(const float* in_nchw, int C, int H, int W,
     }
 }

-static void xca_block(float* x_hwc, int H, int W, int C,
+/*static*/ void xca_block(float* x_hwc, int H, int W, int C,
                       const float* gamma_xca, const float* gamma,
                       /* DW conv for split heads */
                       int n_dw_splits, const int* dw_split_sizes,
@@ -451,7 +451,7 @@ static void xca_block(float* x_hwc, int H, int W, int C,
  * AVX2 optimized: vectorize across output channels (Cout). */
 /* conv2d_hwc with pre-transposed weights in [Cin*KK, Cout] layout.
  * At load time, call conv2d_hwc_reorder_weights() to transpose OIHW → [Cin*KK, Cout]. */
-static void conv2d_hwc_reorder_weights(float* w, int Cout, int Cin, int KK) {
+/*static*/ void conv2d_hwc_reorder_weights(float* w, int Cout, int Cin, int KK) {
     /* In-place transpose from [Cout, Cin*KK] to [Cin*KK, Cout] */
     float* tmp = (float*)malloc((size_t)Cout * Cin * KK * sizeof(float));
     memcpy(tmp, w, (size_t)Cout * Cin * KK * sizeof(float));
@@ -461,7 +461,7 @@ static void conv2d_hwc_reorder_weights(float* w, int Cout, int Cin, int KK) {
     free(tmp);
 }

-static void conv2d_hwc(const float* in_hwc, int Cin, int H, int W,
+/*static*/ void conv2d_hwc(const float* in_hwc, int Cin, int H, int W,
                        const float* w, /* REORDERED to [Cin*KK, Cout] */
                        const float* b, int Cout, int K, int stride,
                        float* out_hwc) {
@@ -618,7 +618,7 @@ static void _mlp_rows(void* ctx_, int start, int end) {

 /* ============ ConvNeXt Block (HWC in/out, NCHW for DW) ============ */
 /* x[HW,C] → LN → DW Conv → gamma*x → LN → MLP(4 MatMul) → +residual */
-static void convnext_block(float* x_hwc, int H, int W, int C,
+/*static*/ void convnext_block(float* x_hwc, int H, int W, int C,
                            const float* gamma,
                            const float* dw_w, const float* dw_b, int K,
                            const float* ln_w, const float* ln_b,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions